Parallel port address auto detect
-
Hi guys, is there any article or tutorial shown that how to detect parallel port address of computer automatically? no i just make simple stuff to work with the parallel port but to make the stuff work on other computers i want to make it can detect the port address automatically instead of key in the address. Thank U for ur help in advance!!:-O
-
Hi guys, is there any article or tutorial shown that how to detect parallel port address of computer automatically? no i just make simple stuff to work with the parallel port but to make the stuff work on other computers i want to make it can detect the port address automatically instead of key in the address. Thank U for ur help in advance!!:-O
#include #define TEST_WINDOWS_NT (!(GetVersion() & 0x80000000)) /********************************************************************* ******************/ int GetParallelControllerKey(char *parKey) { HKEY hKey; char myData[255]; LONG res; DWORD mySize; FILETIME ftLastWriteTime; if (NULL==parKey) return(-1); *parKey=0; char myKey[255]; sprintf(myKey,";HARDWARE\\DESCRIPTION\\System";); res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey, 0, KEY_READ, &hKey); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex1; char myKey1[255]; for (dwIndex1=0;dwIndex1<=10;dwIndex1++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey,dwIndex1,myData,&;mySize,NULL,NULL,NULL,&ftLastWriteT ime); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 1 { strcpy(myKey1,myKey); strcat(myKey1,"\\"); strcat(myKey1,myData); HKEY hKey1; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey1, 0, KEY_READ, &hKey1); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex2; char myKey2[255]; for (dwIndex2=0;dwIndex2<=10;dwIndex2++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey1,dwIndex2,myData,&mySize,NULL,NULL,NULL,&;ftLastWrite Time); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 2 { strcpy(myKey2,myKey1); strcat(myKey2,";\\";); strcat(myKey2,myData); HKEY hKey2; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey2, 0, KEY_READ, &;hKey2); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex3; for (dwIndex3=0;dwIndex3<=10;dwIndex3++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey2,dwIndex3,myData,&;mySize,NULL,NULL,NULL,&;ftLastWrite Time); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 3 { if (0==strcmp(myData,";ParallelController";) ) { strcpy(parKey,myKey2); strcat(parKey,";\\";); strcat(parKey,myDat
-
#include #define TEST_WINDOWS_NT (!(GetVersion() & 0x80000000)) /********************************************************************* ******************/ int GetParallelControllerKey(char *parKey) { HKEY hKey; char myData[255]; LONG res; DWORD mySize; FILETIME ftLastWriteTime; if (NULL==parKey) return(-1); *parKey=0; char myKey[255]; sprintf(myKey,";HARDWARE\\DESCRIPTION\\System";); res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey, 0, KEY_READ, &hKey); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex1; char myKey1[255]; for (dwIndex1=0;dwIndex1<=10;dwIndex1++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey,dwIndex1,myData,&;mySize,NULL,NULL,NULL,&ftLastWriteT ime); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 1 { strcpy(myKey1,myKey); strcat(myKey1,"\\"); strcat(myKey1,myData); HKEY hKey1; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey1, 0, KEY_READ, &hKey1); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex2; char myKey2[255]; for (dwIndex2=0;dwIndex2<=10;dwIndex2++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey1,dwIndex2,myData,&mySize,NULL,NULL,NULL,&;ftLastWrite Time); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 2 { strcpy(myKey2,myKey1); strcat(myKey2,";\\";); strcat(myKey2,myData); HKEY hKey2; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey2, 0, KEY_READ, &;hKey2); if (res!=ERROR_SUCCESS) return(-1); DWORD dwIndex3; for (dwIndex3=0;dwIndex3<=10;dwIndex3++) { mySize=sizeof(myData); res = RegEnumKeyEx(hKey2,dwIndex3,myData,&;mySize,NULL,NULL,NULL,&;ftLastWrite Time); if (res==ERROR_SUCCESS) // ERROR_SUCCESS 3 { if (0==strcmp(myData,";ParallelController";) ) { strcpy(parKey,myKey2); strcat(parKey,";\\";); strcat(parKey,myDat
Hi, Anthony, thank you for reply. i m trying to use the one u suggest. but the code is hard to understand. in case, i really dun know how the parameter "myPort" which in etAddressLptPort GetAddressLptPortInTheRegistry GetAddressLptPortInTheMemory hv been used. u have any idear abt it. btw i m trying to get that book to c how. thank u very much!:-D