wince下在机器上装载虚拟串口驱动失败的问题!
[复制链接]
在模拟器下,装载成功,在真实机器上总是报错,DW代码为2,翻译出来是:系统找不到指定的文件!
以下是我的代码,请大虾们过目:
LONG retVal = 0;
TCHAR szDevKey[MAX_PATH]={0};
wsprintf(szDevKey,_T("Drivers\\myvircom\\simcom%d"),uPort);
TCHAR szDllName[]=GPS_SIMCOMDLL;
TCHAR szPrefix[]=_T("COM");
TCHAR szFriendlyName[50];
wsprintf(szFriendlyName,_T("COM%u myvircom"),uPort);
DWORD dwIndex=uPort;
DWORD dwOrder=0;
DWORD dwDeviceIndex=uPort;
HKEY hKey;
//Open the registry key and and these values
if(ERROR_SUCCESS!=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szDevKey,0,NULL,
0,KEY_ALL_ACCESS,NULL,&hKey,NULL))
{
m_strerror=CString("生成:")+szDevKey+_T("失败!");
return FALSE;
}
RegSetValueEx(hKey,_T("DeviceArrayIndex"),0,REG_DWORD,(PBYTE)&dwDeviceIndex,sizeof(DWORD));
//Create the key specifying the Prefix
RegSetValueEx(hKey,_T("Prefix"),0,REG_SZ,(const BYTE*)szPrefix,sizeof(szPrefix));
//Create the key specifying the dll name
if(ERROR_SUCCESS!=RegSetValueEx(hKey,_T("Dll"),0,REG_SZ,(const BYTE*)szDllName,
sizeof(szDllName)))
{
m_strerror=CString("生成:")+szDevKey+_T("Dll失败!");
return FALSE;
}
RegSetValueEx(hKey,_T("Order"),0,REG_DWORD,(LPBYTE)&dwOrder,sizeof(DWORD));
RegSetValueEx(hKey,_T("Index"),0,REG_DWORD,(LPBYTE)&dwIndex,sizeof(DWORD));
//Create the key specifying the FriendlyName
RegSetValueEx(hKey,_T("FriendlyName"),0,REG_SZ,(const BYTE*)szFriendlyName,sizeof(szFriendlyName));
RegCloseKey(hKey);
m_hHandleGiveAway=ActivateDeviceEx(szDevKey,NULL,0,NULL);
DWORD dw = ::GetLastError();