XPUSR
asked on
header file conflict in VC++6.0[WinXP]
Hi,
I am attempting to gain access to a USB Device on my PC. I have wrote a simple program in Visual C++ 6.0. The problem is that when I include the "hidsdi.h" header file and compile the program I get numerous errors:
example errors:
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(52) : warning C4005: 'STATUS_WAIT_0' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1053) : see previous definition of 'STATUS_WAIT_0'
I presum there is some conflict between the ntstatus.h and the winnt.h files but this only occurs when I include the "hidsdi.h" file.
Any suggestions will be appreciated,
Thanks
J
I am attempting to gain access to a USB Device on my PC. I have wrote a simple program in Visual C++ 6.0. The problem is that when I include the "hidsdi.h" header file and compile the program I get numerous errors:
example errors:
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
I presum there is some conflict between the ntstatus.h and the winnt.h files but this only occurs when I include the "hidsdi.h" file.
Any suggestions will be appreciated,
Thanks
J
ASKER
I gave it a go but it didn't make any difference??
any other ideas??
Thanks
any other ideas??
Thanks
Did you do a 'clean' before building the project again?
ASKER
Yes,
I did a clean...
I only posted 2 of the errrors I actually get the following list,
:\program files\microsoft visual studio\vc98\include\ntstat us.h(52) : warning C4005: 'STATUS_WAIT_0' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1053) : see previous definition of 'STATUS_WAIT_0'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(58) : warning C4005: 'STATUS_ABANDONED_WAIT_0' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1054) : see previous definition of 'STATUS_ABANDONED_WAIT_0'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(60) : warning C4005: 'STATUS_USER_APC' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1055) : see previous definition of 'STATUS_USER_APC'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(63) : warning C4005: 'STATUS_TIMEOUT' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1056) : see previous definition of 'STATUS_TIMEOUT'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(64) : warning C4005: 'STATUS_PENDING' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1057) : see previous definition of 'STATUS_PENDING'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(96) : warning C4005: 'STATUS_SEGMENT_NOTIFICATI ON' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1058) : see previous definition of 'STATUS_SEGMENT_NOTIFICATI ON'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(135) : warning C4005: 'STATUS_GUARD_PAGE_VIOLATI ON' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1059) : see previous definition of 'STATUS_GUARD_PAGE_VIOLATI ON'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(136) : warning C4005: 'STATUS_DATATYPE_MISALIGNM ENT' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1060) : see previous definition of 'STATUS_DATATYPE_MISALIGNM ENT'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(137) : warning C4005: 'STATUS_BREAKPOINT' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1061) : see previous definition of 'STATUS_BREAKPOINT'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(138) : warning C4005: 'STATUS_SINGLE_STEP' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1062) : see previous definition of 'STATUS_SINGLE_STEP'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(182) : warning C4005: 'STATUS_ACCESS_VIOLATION' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1063) : see previous definition of 'STATUS_ACCESS_VIOLATION'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(183) : warning C4005: 'STATUS_IN_PAGE_ERROR' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1064) : see previous definition of 'STATUS_IN_PAGE_ERROR'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(185) : warning C4005: 'STATUS_INVALID_HANDLE' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1065) : see previous definition of 'STATUS_INVALID_HANDLE'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(200) : warning C4005: 'STATUS_NO_MEMORY' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1066) : see previous definition of 'STATUS_NO_MEMORY'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(206) : warning C4005: 'STATUS_ILLEGAL_INSTRUCTIO N' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1067) : see previous definition of 'STATUS_ILLEGAL_INSTRUCTIO N'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(214) : warning C4005: 'STATUS_NONCONTINUABLE_EXC EPTION' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1068) : see previous definition of 'STATUS_NONCONTINUABLE_EXC EPTION'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(215) : warning C4005: 'STATUS_INVALID_DISPOSITIO N' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1069) : see previous definition of 'STATUS_INVALID_DISPOSITIO N'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(316) : warning C4005: 'STATUS_ARRAY_BOUNDS_EXCEE DED' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1070) : see previous definition of 'STATUS_ARRAY_BOUNDS_EXCEE DED'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(317) : warning C4005: 'STATUS_FLOAT_DENORMAL_OPE RAND' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1071) : see previous definition of 'STATUS_FLOAT_DENORMAL_OPE RAND'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(318) : warning C4005: 'STATUS_FLOAT_DIVIDE_BY_ZE RO' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1072) : see previous definition of 'STATUS_FLOAT_DIVIDE_BY_ZE RO'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(319) : warning C4005: 'STATUS_FLOAT_INEXACT_RESU LT' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1073) : see previous definition of 'STATUS_FLOAT_INEXACT_RESU LT'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(320) : warning C4005: 'STATUS_FLOAT_INVALID_OPER ATION' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1074) : see previous definition of 'STATUS_FLOAT_INVALID_OPER ATION'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(321) : warning C4005: 'STATUS_FLOAT_OVERFLOW' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1075) : see previous definition of 'STATUS_FLOAT_OVERFLOW'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(322) : warning C4005: 'STATUS_FLOAT_STACK_CHECK' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1076) : see previous definition of 'STATUS_FLOAT_STACK_CHECK'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(323) : warning C4005: 'STATUS_FLOAT_UNDERFLOW' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1077) : see previous definition of 'STATUS_FLOAT_UNDERFLOW'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(324) : warning C4005: 'STATUS_INTEGER_DIVIDE_BY_ ZERO' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1078) : see previous definition of 'STATUS_INTEGER_DIVIDE_BY_ ZERO'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(325) : warning C4005: 'STATUS_INTEGER_OVERFLOW' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1079) : see previous definition of 'STATUS_INTEGER_OVERFLOW'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(326) : warning C4005: 'STATUS_PRIVILEGED_INSTRUC TION' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1080) : see previous definition of 'STATUS_PRIVILEGED_INSTRUC TION'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(429) : warning C4005: 'STATUS_STACK_OVERFLOW' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1081) : see previous definition of 'STATUS_STACK_OVERFLOW'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(490) : warning C4005: 'STATUS_CONTROL_C_EXIT' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1082) : see previous definition of 'STATUS_CONTROL_C_EXIT'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(749) : warning C4005: 'STATUS_FLOAT_MULTIPLE_FAU LTS' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1083) : see previous definition of 'STATUS_FLOAT_MULTIPLE_FAU LTS'
g:\program files\microsoft visual studio\vc98\include\ntstat us.h(750) : warning C4005: 'STATUS_FLOAT_MULTIPLE_TRA PS' : macro redefinition
g:\program files\microsoft visual studio\vc98\include\winnt. h(1084) : see previous definition of 'STATUS_FLOAT_MULTIPLE_TRA PS'
g:\program files\microsoft visual studio\vc98\include\winddk .h(117) : error C2065: '__asm__' : undeclared identifier
g:\program files\microsoft visual studio\vc98\include\winddk .h(117) : error C2146: syntax error : missing ';' before identifier '__volatile__'
g:\program files\microsoft visual studio\vc98\include\winddk .h(117) : error C2065: '__volatile__' : undeclared identifier
g:\program files\microsoft visual studio\vc98\include\winddk .h(118) : error C2143: syntax error : missing ')' before ':'
g:\program files\microsoft visual studio\vc98\include\winddk .h(120) : error C2059: syntax error : ')'
g:\program files\microsoft visual studio\vc98\include\winddk .h(130) : error C2146: syntax error : missing ';' before identifier 'KSPIN_LOCK'
g:\program files\microsoft visual studio\vc98\include\winddk .h(130) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
host.exe - 7 error(s), 32 warning(s)
I did a clean...
I only posted 2 of the errrors I actually get the following list,
:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\ntstat
g:\program files\microsoft visual studio\vc98\include\winnt.
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
g:\program files\microsoft visual studio\vc98\include\winddk
Error executing cl.exe.
host.exe - 7 error(s), 32 warning(s)
Ooops - you are not supposed to have DDK headers in your VC6 include directory, this will cause *tons* of other problems...
ASKER
Do you know how I can solve this?
Do I have to get my hands on the MS DDK, or can I simply delete these DDK headers from the include directory and if I do this where do I put them?
Sorry for the idiot questions!!!
Thanks
J
Do I have to get my hands on the MS DDK, or can I simply delete these DDK headers from the include directory and if I do this where do I put them?
Sorry for the idiot questions!!!
Thanks
J
>>can I simply delete these DDK headers from the include directory
Nope, you most likely have already overwritten a few - the DDK headers include e.g. a 'winnt.h' also. If they came separately, see which files you copied there. Usually, you would keep all of them in a separate directory. BTW, I just noticed that 'hidsdi.h' also is a DDK file - why would you need to include that?
Nope, you most likely have already overwritten a few - the DDK headers include e.g. a 'winnt.h' also. If they came separately, see which files you copied there. Usually, you would keep all of them in a separate directory. BTW, I just noticed that 'hidsdi.h' also is a DDK file - why would you need to include that?
ASKER
Here is my code
I am going to reinstall VC++, hopefully this will restore all to the way it was before!
Do I need to get MSDDK? as I just downloaded the ddk files from the net and copied them to my vc++ include folder?
Thanks again
//************************ ********** ********** ***
#include "windows.h"
#include "stdio.h"
#include "setupapi.h"
#include "hidsdi.h"
int main(int argc, char* argv[])
{
char data[4];
char data2[4];
DWORD junk;
char temp;
HANDLE hdevice = CreateFile("\\\\.\\h:", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hdevice == INVALID_HANDLE_VALUE)
{
printf("Unable to open the device - error %d\n", GetLastError());
return 1;
}
else
{
printf("Access to usb device granted:\n");
}
GUID hidGUID; //declaring GUID, this is where the problem starts
while(1){
if (ReadFile(hdevice, data2, 1, &junk, NULL))
{
printf("\nThe device returned: ");
for (int i = 0; i < 4; i++)
printf("%c",data2[i]);
printf("\n\nCNTL C to exit\n\n");
}
else
{
printf("Error: NORead\n\n");
}
}
CloseHandle(hdevice);
return 0;
}
I am going to reinstall VC++, hopefully this will restore all to the way it was before!
Do I need to get MSDDK? as I just downloaded the ddk files from the net and copied them to my vc++ include folder?
Thanks again
//************************
#include "windows.h"
#include "stdio.h"
#include "setupapi.h"
#include "hidsdi.h"
int main(int argc, char* argv[])
{
char data[4];
char data2[4];
DWORD junk;
char temp;
HANDLE hdevice = CreateFile("\\\\.\\h:", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hdevice == INVALID_HANDLE_VALUE)
{
printf("Unable to open the device - error %d\n", GetLastError());
return 1;
}
else
{
printf("Access to usb device granted:\n");
}
GUID hidGUID; //declaring GUID, this is where the problem starts
while(1){
if (ReadFile(hdevice, data2, 1, &junk, NULL))
{
printf("\nThe device returned: ");
for (int i = 0; i < 4; i++)
printf("%c",data2[i]);
printf("\n\nCNTL C to exit\n\n");
}
else
{
printf("Error: NORead\n\n");
}
}
CloseHandle(hdevice);
return 0;
}
>>Do I need to get MSDDK?
Only if you want to create a device driver.
>>GUID hidGUID; //declaring GUID, this is where the problem starts
If you need the declarations for GUID, include 'objbase.h'.
Only if you want to create a device driver.
>>GUID hidGUID; //declaring GUID, this is where the problem starts
If you need the declarations for GUID, include 'objbase.h'.
ASKER
I don't need to create a device driver just need to get read access to a usb device.
I need to declare "HidD_GetHidGuid()" amoung others.
As far as I know this belongs to 'hidsdi.h'?
I need to declare "HidD_GetHidGuid()" amoung others.
As far as I know this belongs to 'hidsdi.h'?
>>I need to declare "HidD_GetHidGuid()" amoung others.
>>As far as I know this belongs to 'hidsdi.h'?
Hmm, 'hidsdi.h' does not use 'ntstatus.h', so this file should not be the problem...
>>As far as I know this belongs to 'hidsdi.h'?
Hmm, 'hidsdi.h' does not use 'ntstatus.h', so this file should not be the problem...
ASKER
but hidsdi.h calls hidusage.h and "hidpi.h" which in turn call other .h files which use ntstatus.h and this brings me back to my original errors...
I think I need the MSDDK as this contains all these files?
I think I need the MSDDK as this contains all these files?
>>I think I need the MSDDK as this contains all these files?
Yes, or just extract the declaration:
void __stdcall
HidD_GetHidGuid (
LPGUID HidGuid
);
Yes, or just extract the declaration:
void __stdcall
HidD_GetHidGuid (
LPGUID HidGuid
);
ASKER
i extracted the function void __stdcall HidD_GetHidGuid ( LPGUID HidGuid);
It works...
But when I try to pass HidGuid into it I get an error
ERROR:
host.obj : error LNK2001: unresolved external symbol "void __stdcall HidD_GetHidGuid(struct _GUID *)"(HidD_GetHidGuid@@YGXPA U_GUID@@@Z )
//************************ *******
//MY CODE
//WITH void __stdcallHidD_GetHidGuid (LPGUID HidGuid) INSIDE MAIN
int main(int argc, char* argv[])
{
void __stdcallHidD_GetHidGuid (LPGUID HidGuid);
GUID HidGuid;
HidD_GetHidGuid(&HidGuid);
return 0;
}
//************************ ******
AND IF I PUT THE void __stdcallHidD_GetHidGuid (LPGUID HidGuid); outside main I get this error
g:\documents and settings\fin\desktop\fyp-n ov\usbwind ows\host\h ost.cpp(12 1) : error C2373: 'HidD_GetHidGuid' : redefinition; different type modifiers
I must be doing something stupid?? Have been working on this for the past few hours now and still no sucess.
Thanks for your time
It works...
But when I try to pass HidGuid into it I get an error
ERROR:
host.obj : error LNK2001: unresolved external symbol "void __stdcall HidD_GetHidGuid(struct _GUID *)"(HidD_GetHidGuid@@YGXPA
//************************
//MY CODE
//WITH void __stdcallHidD_GetHidGuid (LPGUID HidGuid) INSIDE MAIN
int main(int argc, char* argv[])
{
void __stdcallHidD_GetHidGuid (LPGUID HidGuid);
GUID HidGuid;
HidD_GetHidGuid(&HidGuid);
return 0;
}
//************************
AND IF I PUT THE void __stdcallHidD_GetHidGuid (LPGUID HidGuid); outside main I get this error
g:\documents and settings\fin\desktop\fyp-n
I must be doing something stupid?? Have been working on this for the past few hours now and still no sucess.
Thanks for your time
You need to either add a .lib file or load the DLL the function resides in dynamically. The lib would either be hidclass.lib or hidparse.lib (give it a try, I really don't know which one it is)
HidD_GetHidGuid() is probably a function with C namemangling and the declaration shoud be inside extern "C".
ASKER
JensUniweb I put the code in an extern "C", unfortunately it had no effect...
jkr, i think you are on the right track, the HidD_GetHidGuid() function resides in hid.lib but how do I load it dynamically? I looked on the net for info on this but got nothing?
jkr, i think you are on the right track, the HidD_GetHidGuid() function resides in hid.lib but how do I load it dynamically? I looked on the net for info on this but got nothing?
To load it dynamicly you have to do a loadlibrary() and then a getprocaddress().
Do you know the name in the .dll file. Is it like _Hid... or just Hid.... If it is without the _ you problably need to use __winapi or something like that. Not puting the _ infront of the name looking for it in the dll.
All this is called namemangling.
Do you know the name in the .dll file. Is it like _Hid... or just Hid.... If it is without the _ you problably need to use __winapi or something like that. Not puting the _ infront of the name looking for it in the dll.
All this is called namemangling.
ASKER
the file is just "hid.dll".
do I pass the lib name into the loadlibrary function and then call get procaddress?
loadlibrary("hid.dll");
getprocaddress();
Or how do i do it??
Thanks
do I pass the lib name into the loadlibrary function and then call get procaddress?
loadlibrary("hid.dll");
getprocaddress();
Or how do i do it??
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
extern "C" void __stdcall HidD_GetHidGuid ( LPGUID HidGuid );
That should do the trick to compile. If the name in the .lib/.def is HidD_GetHidGuid with no _ infront and no C++ namemangling.
That should do the trick to compile. If the name in the .lib/.def is HidD_GetHidGuid with no _ infront and no C++ namemangling.
ASKER
I am still having problems using LoadLibrary,
This is the code I am using.
LoadLibrary("G:\Program Files\Microsoft Visual Studio\VC98\Lib\hid.dll");
HHMODULE hModule=GetModuleHandle("G :\Program Files\Microsoft Visual Studio\VC98\Lib\hid.dll");
GetProcAddress(hModule,Hid D_GetHidGu id);
GUID HidGuid; //Parameter I need to pass to the HidD_Get... function
HidD_GetHidGuid(&HidGuid); //This is the function I need access to!
OUTSIDE MAIN
extern "C" void __stdcall HidD_GetHidGuid (LPGUID HidGuid);
The compiler errors i recieve are
error C2065: 'HHMODULE' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hModule'
error C2065: 'hModule' : undeclared identifier
error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
error C2065: 'HidD_GetHidGuid' : undeclared identifier
This is the code I am using.
LoadLibrary("G:\Program Files\Microsoft Visual Studio\VC98\Lib\hid.dll");
HHMODULE hModule=GetModuleHandle("G
GetProcAddress(hModule,Hid
GUID HidGuid; //Parameter I need to pass to the HidD_Get... function
HidD_GetHidGuid(&HidGuid);
OUTSIDE MAIN
extern "C" void __stdcall HidD_GetHidGuid (LPGUID HidGuid);
The compiler errors i recieve are
error C2065: 'HHMODULE' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hModule'
error C2065: 'hModule' : undeclared identifier
error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
error C2065: 'HidD_GetHidGuid' : undeclared identifier
>>This is the code I am using.
This should be more like
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
HINSTANCE hDll = LoadLibrary("hid.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hModule,"Hi dD_GetHidG uid");
GUID HidGuid; //Parameter I need to pass to the HidD_Get... function
pHidD_GetHidGuid(&HidGuid) ; //This is the function I need access to!
This should be more like
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
HINSTANCE hDll = LoadLibrary("hid.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hModule,"Hi
GUID HidGuid; //Parameter I need to pass to the HidD_Get... function
pHidD_GetHidGuid(&HidGuid)
ASKER
I am still not getting this... Below is my code... Can you understand what is happening???
I am sorry to annoy you again so ill throw in an extra 100 points...
This is really bugging me so your help is really appreciated,
Thanks again,
J
int main
{
HINSTANCE hDll = LoadLibrary("hid.dll");
HHMODULE hModule=GetModuleHandle("h id.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hModule,"Hi dD_GetHidG uid");
//FUNCTION I NEED ACCESS TO
GUID HidGuid;
HidD_GetHidGuid(&HidGuid);
}
extern "C" void __stdcall HidD_GetHidGuid (LPGUID HidGuid);
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
NOW MY ERRORS(10):
error C2065: 'HHMODULE' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hModule'
error C2065: 'hModule' : undeclared identifier
error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2065: 'pfnHidD_GetHidGuid' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'pHidD_GetHidGuid'
error C2065: 'pHidD_GetHidGuid' : undeclared identifier
warning C4129: 'U' : unrecognized character escape sequence
error C2065: 'HidD_GetHidGuid' : undeclared identifier
error C2373: 'HidD_GetHidGuid' : redefinition; different type modifiers
error C2378: 'pfnHidD_GetHidGuid' : redefinition; symbol cannot be overloaded with a typedef
I am sorry to annoy you again so ill throw in an extra 100 points...
This is really bugging me so your help is really appreciated,
Thanks again,
J
int main
{
HINSTANCE hDll = LoadLibrary("hid.dll");
HHMODULE hModule=GetModuleHandle("h
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hModule,"Hi
//FUNCTION I NEED ACCESS TO
GUID HidGuid;
HidD_GetHidGuid(&HidGuid);
}
extern "C" void __stdcall HidD_GetHidGuid (LPGUID HidGuid);
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
NOW MY ERRORS(10):
error C2065: 'HHMODULE' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hModule'
error C2065: 'hModule' : undeclared identifier
error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2065: 'pfnHidD_GetHidGuid' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'pHidD_GetHidGuid'
error C2065: 'pHidD_GetHidGuid' : undeclared identifier
warning C4129: 'U' : unrecognized character escape sequence
error C2065: 'HidD_GetHidGuid' : undeclared identifier
error C2373: 'HidD_GetHidGuid' : redefinition; different type modifiers
error C2378: 'pfnHidD_GetHidGuid' : redefinition; symbol cannot be overloaded with a typedef
Use
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
HINSTANCE hDll = LoadLibrary("hid.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hDll,"HidD_ GetHidGuid ");
GUID HidGuid;
pHidD_GetHidGuid(&HidGuid) ;
There is no such thing as a HHMODULE and also no need to call 'GetModuleHandle()'
typedef void ( __stdcall *pfnHidD_GetHidGuid) ( LPGUID HidGuid );
HINSTANCE hDll = LoadLibrary("hid.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hDll,"HidD_
GUID HidGuid;
pHidD_GetHidGuid(&HidGuid)
There is no such thing as a HHMODULE and also no need to call 'GetModuleHandle()'
ASKER
Thanks,
that has brought me down to one error
with the following line of code
//************************ ********** **
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hDll,"HidD_ GetHidGuid ");
//************************ ********** **
ERROR:
: error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(void)' to 'void (__stdcall *)(struct _GUID *)'
that has brought me down to one error
with the following line of code
//************************
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hDll,"HidD_
//************************
ERROR:
: error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(void)' to 'void (__stdcall *)(struct _GUID *)'
Ooops :o)
pfnHidD_GetHidGuid pHidD_GetHidGuid = (pfnHidD_GetHidGuid) GetProcAddress(hDll,"HidD_ GetHidGuid ");
pfnHidD_GetHidGuid pHidD_GetHidGuid = (pfnHidD_GetHidGuid) GetProcAddress(hDll,"HidD_
ASKER
Thanks a million JKR, At long last its working.
I'll up the point 100 for this next question...
I need to do the same for the following function
"BOOLEAN HidD_GetAttributes(IN HANDLE HidDeviceObject,OUT PHIDD_ATTRIBUTES Attributes);"
This is the code I have tried:
int main{
typedef struct _HIDD_ATTRIBUTES {
ULONG Size;
USHORT VendorID;
USHORT ProductID;
USHORT VersionNumber;
} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
typedef int ( __stdcall *pfnHidD_GetAttributes) ( HANDLE HidDeviceObject)(PHIDD_ATT RIBUTES Attributes);
pfnHidD_GetAttributes pHidD_GetAttributes = (pfnHidD_GetAttributes) GetProcAddress(hDll,"HidD_ GetHidGuid ");
pfnHidD_GetAttributes(&Hid DeviceObje ct,&Attrib utes);
}
: error C2091: function returns function
: error C2065: 'HidDeviceObject' : undeclared identifier
: error C2065: 'Attributes' : undeclared identifier
: error C2564: 'int (__cdecl *(__stdcall *)(void *))(struct main::_HIDD_ATTRIBUTES *)' : function-style conversion to builtin type takes only one argument
I'll up the point 100 for this next question...
I need to do the same for the following function
"BOOLEAN HidD_GetAttributes(IN HANDLE HidDeviceObject,OUT PHIDD_ATTRIBUTES Attributes);"
This is the code I have tried:
int main{
typedef struct _HIDD_ATTRIBUTES {
ULONG Size;
USHORT VendorID;
USHORT ProductID;
USHORT VersionNumber;
} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
typedef int ( __stdcall *pfnHidD_GetAttributes) ( HANDLE HidDeviceObject)(PHIDD_ATT
pfnHidD_GetAttributes pHidD_GetAttributes = (pfnHidD_GetAttributes) GetProcAddress(hDll,"HidD_
pfnHidD_GetAttributes(&Hid
}
: error C2091: function returns function
: error C2065: 'HidDeviceObject' : undeclared identifier
: error C2065: 'Attributes' : undeclared identifier
: error C2564: 'int (__cdecl *(__stdcall *)(void *))(struct main::_HIDD_ATTRIBUTES *)' : function-style conversion to builtin type takes only one argument
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a million....
All is working for now!
J
All is working for now!
J
You're welcome :o)
Hi XPUSR,
I have some questions about USB and I hope you would help me.
My email is : Ayd192@Hotmail.com
Thanx
I have some questions about USB and I hope you would help me.
My email is : Ayd192@Hotmail.com
Thanx
sir,
what are the nescessary things to develop a Device driver program.specifically USB.Is it possible to design a device driver using MFC,without DDK.please send me a sample code with explanation.
with regards,
Antony
what are the nescessary things to develop a Device driver program.specifically USB.Is it possible to design a device driver using MFC,without DDK.please send me a sample code with explanation.
with regards,
Antony
sir,
when i run my simple USB program,there are some errors in winddk.h.please tell me how can i rectify it.whare i can get windows DDK. My mail id : maharaj_be@yahoo.co.in
Antony
when i run my simple USB program,there are some errors in winddk.h.please tell me how can i rectify it.whare i can get windows DDK. My mail id : maharaj_be@yahoo.co.in
Antony
#include <windows.h>
//...
#include "hidsdi.h"
change it to
#include <windows.h>
//...
#define WIN32_NO_STATUS
#include "hidsdi.h"
#undef WIN32_NO_STATUS