- C/C++ code
LONG a=RegCreateKeyEx(HKEY_LOCAL_MACHINE,DEV_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,&m_hKey,&dwDisp); LONG b=RegSetValueEx(m_hKey,TEXT("Order"), 0, REG_DWORD, (const BYTE *) szValue, sizeof(DWORD)); LONG c=RegSetValueEx(m_hKey,TEXT("Index"), 0, REG_DWORD, (const BYTE *) szValue1, sizeof(DWORD)); LONG e=RegSetValueEx(m_hKey,TEXT("Dll"), 0, REG_SZ, (LPBYTE)TEXT("\\Program Files\\wdll\\wdll.dll"), 1 + sizeof(TEXT("\\Program Files\\wdll\\wdll.dll"))); LONG d=RegSetValueEx(m_hKey,TEXT("Prefix"), 0, REG_SZ ,(LPBYTE)TEXT("FKE"), 1 + sizeof(TEXT("FKE"))); DWORD dwParam = 89; //HANDLE hd = ActivateDeviceEx(DEV_KEY,NULL,0,&dwParam); HANDLE hd = ActivateDeviceEx(DEV_KEY,NULL,0,&dwParam); if(hd==NULL){printf("%d",GetLastError());return 0;}/*HANDLE hDriver = CreateFile(TEXT("FKE1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);*/HANDLE hDriver = CreateFile(TEXT("FKE1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hDriver==INVALID_HANDLE_VALUE){ printf("%d",GetLastError()); DeactivateDevice(hd); return 0; }
高手来说明一下 或者是dll文件的问题
------解决方案--------------------
正要回的時候看到結帖率=0....... 加油
------解决方案--------------------
------解决方案--------------------
返回55是说明驱动不存在,很有可能是在HKEY_LOCAL_MACHINE\Drivers\BuiltIn\下面没有对应的注册项,加上去应该就没有问题了!
------解决方案--------------------
Registry "Dll" 不可以寫路徑, 請將該 dll copy to \Windows folder 下.
Paul, Chao @ Techware
------解决方案--------------------
给个例子:
- C/C++ code
RegisterDevice (L"GGD", 1, L"GPRS.dll", NULL);Handle hSMD = CreateFile(L"GGD1:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );