C#:
string[] ConfigurationString = new string[8];
ConfigurationString[0] = Location;
ConfigurationString[1] = LocalCalls;
ConfigurationString[2] = LongDistanceCalls;
ConfigurationString[3] = InternationalCalls;
ConfigurationString[4] = AreaCode;
ConfigurationString[5] = DisableCallWaitingSequence;
ConfigurationString[6] = CountryCode;
ConfigurationString[7] = ToneOrPulse;
RegistryKey rk = Registry.CurrentUser;
using (RegistryKey rk1 = rk.CreateSubKey("ControlPanel\
{
rk1.SetValue(KeyName, ConfigurationString);
rk1.Close();
}
C++: (not tested yet!)
HKEY hKey = NULL;
DWORD dataType = REG_MULTI_SZ;
LONG retVal = 0;
LONG ConfigurationStringSize = 512;
WCHAR *ConfigurationString = new WCHAR[ConfigurationStringSize]
memset(ConfigurationString,'\
// Build the configuration string.
wcscat(ConfigurationString, Location);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, LocalCalls);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, LongDistanceCalls);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, InternationalCalls);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, AreaCode);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, DisableCallWaitingSequence);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, CountryCode);
wcscat(ConfigurationString, TEXT("$"));
wcscat(ConfigurationString, ToneOrPulse);
wcscat(ConfigurationString, TEXT("$"));
// Format the string correctly.
int ConfigStringLen = wcslen(ConfigurationString);
for(int x = 0; x < ConfigStringLen; ++x)
{
if(ConfigurationString[x] == '$')
ConfigurationString[x] = '\0';
}
// Open the registry key.
retVal = RegOpenKeyEx(HKEY_CURRENT_USER , TEXT("ControlPanel\\Dial\\
if(retVal != ERROR_SUCCESS)
{
delete [] ConfigurationString;
return false;
}
// Set the value of the key.
retVal = RegSetValueEx(hKey, KeyName, NULL, dataType, (PBYTE)ConfigurationString, ConfigurationStringSize);
RegCloseKey(hKey);
delete [] ConfigurationString;
return retVal != ERROR_SUCCESS ? false : true;
------------------------------
C#:
private bool GetBinaryBluetoothAddress(
{
try
{
//00:03:c9:56:0c:EE
string[] sTmp = sBluetoothAddress.Split(':');
bBTAddress[0] = Convert.ToByte(sTmp[5], 16);
bBTAddress[1] = Convert.ToByte(sTmp[4], 16);
bBTAddress[2] = Convert.ToByte(sTmp[3], 16);
bBTAddress[3] = Convert.ToByte(sTmp[2], 16);
bBTAddress[4] = Convert.ToByte(sTmp[1], 16);
bBTAddress[5] = Convert.ToByte(sTmp[0], 16);
bBTAddress[6] = 0;
bBTAddress[7] = 0;
return true;
}
catch
{
return false;
}
}
RegistryKey rk = Registry.LocalMachine;
using (RegistryKey rk1 = rk.CreateSubKey("\\Software\\
{
byte[] bA = new byte[8];
if (GetBinaryBluetoothAddress("
{
rk1.SetValue("dxaddress", bA);
MessageBox.Show("Good!");
}
else
MessageBox.Show("Failed!");
rk1.Close();
}
rk.Close();
C++:
unsigned char epwd[9];
//set epwd here
RegSetValueEx(hKey,"keyname",
No comments:
Post a Comment