Re: Registering a Port
- From: "Luca Calligaris" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Apr 2008 07:00:51 +0200
Why are you doing that?and anyway, where is the problem (error) with the
code?
I can see at least a thing: if you call if
RegOpenKeyEx(HKEY_LOCAL_MACHINE,...)
the second parameter won't be if L"HKEY_LOCAL_MACHINE\\Drivers\..." but
simply L"Drivers\...".
Anyway, apart playing with the registry you are not calling ActivateDevice
or RegisterDevice so...?
--
Luca Calligaris
www.eurotech.it
<manuinsis@xxxxxxxxx> ha scritto nel messaggio
news:1a715de2-c618-409c-9377-cb0a8f65300a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
There is some problem while registering my virtual serial port, so
please find the code below this message and let me know if there is
any mistake and if there is anything i've just ignored completely.
The code gets the last opened port index number and increments it by
taking it to a variable and converts it to a string as the
regsetvalueex takes the pointer to a null terminated string as the
parameter and closes it.
//The registry part of code in the com_init function
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"HKEY_LOCAL_MACHINE\\Drivers\
\BuiltIn\\VSP", 0, 0, &hKey) == ERROR_SUCCESS)
{
TCHAR szDriverKey[255];
DWORD dwSize = 255;
DWORD dwType,ManagePort;
if (RegQueryValueEx(hKey, L"Key", 0, &dwType, (BYTE *)szDriverKey,
&dwSize) == ERROR_SUCCESS)
{
printf("after query value");
RegCloseKey(hKey);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szDriverKey, 0, 0, &hKey) ==
ERROR_SUCCESS)
{
printf("after open key");
dwSize=4;
ManagePort=0;
if (RegQueryValueEx(hKey, L"ManagePort", 0, &dwType, (BYTE *)&dwPort,
&dwSize) != ERROR_SUCCESS)
//dwPort = 0;
Index=(int)dwPort;
++Index;
while(Index>0)
{
j=Index%10;
Index=Index/10;
p[k++]=j+'0';
}
p[k]='\0';
while(k!=0)
{
rev[l++]=p[--k];
}
rev[l]='\0';
ptr=rev;
RegSetValueEx(hKey,(LPCWSTR)ptr,0,REG_DWORD,
(BYTE*)&dwPort,sizeof(DWORD));
RegCloseKey(hKey);
}
thanks,
Manu
.
- References:
- Registering a Port
- From: manuinsis
- Registering a Port
- Prev by Date: Registering a Port
- Next by Date: about windows mobile
- Previous by thread: Registering a Port
- Next by thread: about windows mobile
- Index(es):
Relevant Pages
|
|