Registering a Port
- From: manuinsis@xxxxxxxxx
- Date: Mon, 28 Apr 2008 21:50:40 -0700 (PDT)
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
.
- Follow-Ups:
- Re: Registering a Port
- From: Luca Calligaris
- Re: Registering a Port
- Prev by Date: Re: This application requires a newer version of the .NET Compact
- Next by Date: Re: Registering a Port
- Previous by thread: Re: Multiline Edit text select
- Next by thread: Re: Registering a Port
- Index(es):