Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Parallel port address auto detect

Parallel port address auto detect

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jfk_lili
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • J jfk_lili

      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

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      #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

      J 1 Reply Last reply
      0
      • A Anthony_Yio

        #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

        J Offline
        J Offline
        jfk_lili
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups