Solved

header file conflict in VC++6.0[WinXP]

Posted on 2003-11-21
34
6,136 Views
Last Modified: 2013-12-14
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\ntstatus.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
0
Comment
Question by:XPUSR
  • 14
  • 13
  • 4
  • +2
34 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9799592
That is a problem, as both files define these status macros. Quick solution - if you have

#include <windows.h>
//...
#include "hidsdi.h"

change it to

#include <windows.h>
//...
#define WIN32_NO_STATUS
#include "hidsdi.h"
#undef WIN32_NO_STATUS
0
 

Author Comment

by:XPUSR
ID: 9799752
I gave it a go but it didn't make any difference??

any other ideas??

Thanks
0
 
LVL 86

Expert Comment

by:jkr
ID: 9799781
Did you do a 'clean' before building the project again?
0
 

Author Comment

by:XPUSR
ID: 9799845
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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.h(96) : warning C4005: 'STATUS_SEGMENT_NOTIFICATION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1058) : see previous definition of 'STATUS_SEGMENT_NOTIFICATION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(135) : warning C4005: 'STATUS_GUARD_PAGE_VIOLATION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1059) : see previous definition of 'STATUS_GUARD_PAGE_VIOLATION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(136) : warning C4005: 'STATUS_DATATYPE_MISALIGNMENT' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1060) : see previous definition of 'STATUS_DATATYPE_MISALIGNMENT'
g:\program files\microsoft visual studio\vc98\include\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.h(206) : warning C4005: 'STATUS_ILLEGAL_INSTRUCTION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1067) : see previous definition of 'STATUS_ILLEGAL_INSTRUCTION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(214) : warning C4005: 'STATUS_NONCONTINUABLE_EXCEPTION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1068) : see previous definition of 'STATUS_NONCONTINUABLE_EXCEPTION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(215) : warning C4005: 'STATUS_INVALID_DISPOSITION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1069) : see previous definition of 'STATUS_INVALID_DISPOSITION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(316) : warning C4005: 'STATUS_ARRAY_BOUNDS_EXCEEDED' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1070) : see previous definition of 'STATUS_ARRAY_BOUNDS_EXCEEDED'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(317) : warning C4005: 'STATUS_FLOAT_DENORMAL_OPERAND' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1071) : see previous definition of 'STATUS_FLOAT_DENORMAL_OPERAND'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(318) : warning C4005: 'STATUS_FLOAT_DIVIDE_BY_ZERO' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1072) : see previous definition of 'STATUS_FLOAT_DIVIDE_BY_ZERO'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(319) : warning C4005: 'STATUS_FLOAT_INEXACT_RESULT' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1073) : see previous definition of 'STATUS_FLOAT_INEXACT_RESULT'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(320) : warning C4005: 'STATUS_FLOAT_INVALID_OPERATION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1074) : see previous definition of 'STATUS_FLOAT_INVALID_OPERATION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.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\ntstatus.h(326) : warning C4005: 'STATUS_PRIVILEGED_INSTRUCTION' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1080) : see previous definition of 'STATUS_PRIVILEGED_INSTRUCTION'
g:\program files\microsoft visual studio\vc98\include\ntstatus.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\ntstatus.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\ntstatus.h(749) : warning C4005: 'STATUS_FLOAT_MULTIPLE_FAULTS' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1083) : see previous definition of 'STATUS_FLOAT_MULTIPLE_FAULTS'
g:\program files\microsoft visual studio\vc98\include\ntstatus.h(750) : warning C4005: 'STATUS_FLOAT_MULTIPLE_TRAPS' : macro redefinition
        g:\program files\microsoft visual studio\vc98\include\winnt.h(1084) : see previous definition of 'STATUS_FLOAT_MULTIPLE_TRAPS'
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)
0
 
LVL 86

Expert Comment

by:jkr
ID: 9799890
Ooops - you are not supposed to have DDK headers in your VC6 include directory, this will cause *tons* of other problems...
0
 

Author Comment

by:XPUSR
ID: 9799932
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
0
 
LVL 86

Expert Comment

by:jkr
ID: 9799984
>>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?
0
 

Author Comment

by:XPUSR
ID: 9800057
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;
      }
0
 
LVL 86

Expert Comment

by:jkr
ID: 9800131
>>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'.
0
 

Author Comment

by:XPUSR
ID: 9800207
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'?


0
 
LVL 86

Expert Comment

by:jkr
ID: 9800323
>>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...
0
 

Author Comment

by:XPUSR
ID: 9800362
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?
0
 
LVL 86

Expert Comment

by:jkr
ID: 9800380
>>I think I need the MSDDK as this contains all these files?

Yes, or just extract the declaration:

void __stdcall
HidD_GetHidGuid (
    LPGUID   HidGuid
   );

0
 

Author Comment

by:XPUSR
ID: 9800938
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@@YGXPAU_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-nov\usbwindows\host\host.cpp(121) : 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
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 9801544
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)
0
 
LVL 2

Expert Comment

by:JensUniweb
ID: 9802134
HidD_GetHidGuid() is probably a function with C namemangling and the declaration shoud be inside extern "C".
0
 

Author Comment

by:XPUSR
ID: 9802580
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?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Expert Comment

by:JensUniweb
ID: 9802662
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.
0
 

Author Comment

by:XPUSR
ID: 9802851
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
0
 
LVL 2

Assisted Solution

by:JensUniweb
JensUniweb earned 50 total points
ID: 9802967
http://msdn.microsoft.com/library and then search for LoadLibrary().

LoadLibrary() to load the DLL file.
GetProcAddress() to get the memory address of the function/procedure.

You have to rewrite the who use of these functions. Because calling them will bee like.  prtLib->prtFunc( params ). Calling this way I think it is a requirement that prtFunc() is a function using pascal calling convetion. And if you define that in the correct way the normal linking should work. __stdcall should mean pascal calling convention.

It might be better for you to do it the way you tried first. Tell me the name complete name of the function in the .lib/.def that you use to link to it.

0
 
LVL 2

Expert Comment

by:JensUniweb
ID: 9802975
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.
0
 

Author Comment

by:XPUSR
ID: 9803620
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,HidD_GetHidGuid);

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

0
 
LVL 86

Expert Comment

by:jkr
ID: 9803628
>>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,"HidD_GetHidGuid");

GUID HidGuid; //Parameter I need to pass to the HidD_Get... function
pHidD_GetHidGuid(&HidGuid); //This is the function I need access to!
0
 

Author Comment

by:XPUSR
ID: 9806534
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("hid.dll");
pfnHidD_GetHidGuid pHidD_GetHidGuid = GetProcAddress(hModule,"HidD_GetHidGuid");

//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
0
 
LVL 86

Expert Comment

by:jkr
ID: 9806558
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()'
0
 

Author Comment

by:XPUSR
ID: 9806740
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 *)'
0
 
LVL 86

Expert Comment

by:jkr
ID: 9806972
Ooops :o)

pfnHidD_GetHidGuid pHidD_GetHidGuid = (pfnHidD_GetHidGuid) GetProcAddress(hDll,"HidD_GetHidGuid");
0
 

Author Comment

by:XPUSR
ID: 9811850
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_ATTRIBUTES  Attributes);
pfnHidD_GetAttributes pHidD_GetAttributes = (pfnHidD_GetAttributes) GetProcAddress(hDll,"HidD_GetHidGuid");
pfnHidD_GetAttributes(&HidDeviceObject,&Attributes);

}

: 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
0
 
LVL 86

Accepted Solution

by:
jkr earned 350 total points
ID: 9811890
What you tried is pretty close, but it should read

typedef struct _HIDD_ATTRIBUTES {
 ULONG  Size;
 USHORT  VendorID;
 USHORT  ProductID;
 USHORT  VersionNumber;
} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;

typedef int ( __stdcall *pfnHidD_GetAttributes) ( HANDLE  HidDeviceObject, PHIDD_ATTRIBUTES  Attributes);
pfnHidD_GetAttributes pHidD_GetAttributes = (pfnHidD_GetAttributes) GetProcAddress(hDll,"HidD_GetAttributes");
pHidD_GetAttributes (&HidDeviceObject,&Attributes);

The parameter list in the function pointer definition had a typo and you were using the type name for the function call.
0
 

Author Comment

by:XPUSR
ID: 9812476
Thanks a million....

All is working for now!

J
0
 
LVL 86

Expert Comment

by:jkr
ID: 9812486
You're welcome :o)
0
 
LVL 1

Expert Comment

by:Ayd192
ID: 10006004
Hi XPUSR,
I have some questions about USB and I hope you would help me.
My email is : Ayd192@Hotmail.com

Thanx
0
 

Expert Comment

by:antonymanickaraj
ID: 10390164
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
0
 

Expert Comment

by:antonymanickaraj
ID: 10390703
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
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now