Port parallèle
ibra
-
tb -
tb -
Bonjour,
comment peut ton commander le port parallèle d'un ordi avec XP
quand j'exécute le prog écrit en borlan c++,le port parallèle ne répond pas
pourtant le programme ne comprte pas d'erreur seulement le régistre de données du port parallèle ne se comprte pas comme le programme le voudrait ;je voudrais savoir s'il ya une solution.
comment peut ton commander le port parallèle d'un ordi avec XP
quand j'exécute le prog écrit en borlan c++,le port parallèle ne répond pas
pourtant le programme ne comprte pas d'erreur seulement le régistre de données du port parallèle ne se comprte pas comme le programme le voudrait ;je voudrais savoir s'il ya une solution.
A voir également:
- Port parallèle
- Advanced port scanner - Télécharger - Utilitaires
- Port usb bloqué par administrateur ✓ - Forum Windows
- Port wsd ✓ - Forum Réseau
- Port d'imprimante en réseau qui change ✓ - Forum Réseau
- Coût réparation port hdmi tv - Forum Téléviseurs
1 réponse
Allez chercher "inpout32.dll" sur le net... c'est gratuit.
Ensuite, trouver l'adresse physique du port // en faisant comme dans l'exemple suivant qui va la recuperer dans la base de registres:
// MainsPower.cpp: implementation of the MainsPower class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainsPower.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MainsPower::MainsPower()
{
LPPortAddr = GetAddressLptPortInTheRegistry(1);
}
MainsPower::~MainsPower()
{
}
bool MainsPower::TurnOn()
{
Out32(LPPortAddr,0x0a);
return true;
}
bool MainsPower::TurnOff()
{
Out32(LPPortAddr,0x05);
return true;
}
int MainsPower::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,&ftLastWriteTime);
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,&ftLastWriteTime);
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,&ftLastWriteTime);
if (res==ERROR_SUCCESS) //ERROR_SUCCESS 3
{
if
(0==strcmp(myData,"ParallelController") )
{
strcpy(parKey,myKey2);
strcat(parKey,"\\");
strcat(parKey,myData);
return(0);
}
} // ERROR_SUCCESS 3
} // for (dwIndex3
} // // ERROR_SUCCESS 2
} // for (dwIndex2
} // ERROR_SUCCESS 1
} // for (dwIndex1
return(-1);
}
int MainsPower::GetAddressLptPortInTheRegistry(int myPort)
{
HKEY phkResult;
char myKey[255];
char myData[255];
LONG res;
DWORD mySize;
DWORD myType;
res=GetParallelControllerKey(myKey);
if (res < 0)
return(-1);
sprintf(myData,"%s\\%d",myKey,myPort-1);
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myData, 0, KEY_READ, &phkResult);
if (res != ERROR_SUCCESS)
return(-1);
mySize=sizeof(myData);
myType=REG_BINARY;
res=RegQueryValueEx(
phkResult, // handle to key to query
"Configuration Data", // address of name of value to query
NULL, // reserved
&myType, // address of buffer for value type
(unsigned char *)myData, // address of data buffer
&mySize // address of data buffer size
);
if (res != ERROR_SUCCESS)
return(-1);
//printf(";config data port %d 0x14 = 0x%02X 0x15 = 0x%02X\n";,myPort,myData[0x14],myData[0x15]);
return(myData[0x14] | myData[0x15]<<8 );
}
Ensuite, trouver l'adresse physique du port // en faisant comme dans l'exemple suivant qui va la recuperer dans la base de registres:
// MainsPower.cpp: implementation of the MainsPower class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainsPower.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MainsPower::MainsPower()
{
LPPortAddr = GetAddressLptPortInTheRegistry(1);
}
MainsPower::~MainsPower()
{
}
bool MainsPower::TurnOn()
{
Out32(LPPortAddr,0x0a);
return true;
}
bool MainsPower::TurnOff()
{
Out32(LPPortAddr,0x05);
return true;
}
int MainsPower::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,&ftLastWriteTime);
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,&ftLastWriteTime);
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,&ftLastWriteTime);
if (res==ERROR_SUCCESS) //ERROR_SUCCESS 3
{
if
(0==strcmp(myData,"ParallelController") )
{
strcpy(parKey,myKey2);
strcat(parKey,"\\");
strcat(parKey,myData);
return(0);
}
} // ERROR_SUCCESS 3
} // for (dwIndex3
} // // ERROR_SUCCESS 2
} // for (dwIndex2
} // ERROR_SUCCESS 1
} // for (dwIndex1
return(-1);
}
int MainsPower::GetAddressLptPortInTheRegistry(int myPort)
{
HKEY phkResult;
char myKey[255];
char myData[255];
LONG res;
DWORD mySize;
DWORD myType;
res=GetParallelControllerKey(myKey);
if (res < 0)
return(-1);
sprintf(myData,"%s\\%d",myKey,myPort-1);
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myData, 0, KEY_READ, &phkResult);
if (res != ERROR_SUCCESS)
return(-1);
mySize=sizeof(myData);
myType=REG_BINARY;
res=RegQueryValueEx(
phkResult, // handle to key to query
"Configuration Data", // address of name of value to query
NULL, // reserved
&myType, // address of buffer for value type
(unsigned char *)myData, // address of data buffer
&mySize // address of data buffer size
);
if (res != ERROR_SUCCESS)
return(-1);
//printf(";config data port %d 0x14 = 0x%02X 0x15 = 0x%02X\n";,myPort,myData[0x14],myData[0x15]);
return(myData[0x14] | myData[0x15]<<8 );
}