Re: Error message getting addresses.
From: JKop (NULL_at_NULL.NULL)
Date: 07/29/04
- Next message: JKop: "Re: :: before function calls"
- Previous message: Ireneusz SZCZESNIAK: "Re: overhead of using std::sort"
- In reply to: Intermouse: "Error message getting addresses."
- Next in thread: JKop: "Re: Error message getting addresses."
- Reply: JKop: "Re: Error message getting addresses."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Jul 2004 12:35:30 GMT
Intermouse posted:
> Hi
>
> I keep getting an error:
>
> error C2664: 'GetProcAddress' : cannot convert parameter
1 from 'struct
> HINSTANCE__' to 'struct HINSTANCE__ *'
> No user-defined-conversion operator available
that can perform
> this
> conversion, or the operator cannot be called
>
> My code is:
>
>
> HINSTANCE hinstWNASPI32;
> hinstWNASPI32=LoadLibrary("WNASPI32");
>
> DWORD (*pfnGetASPI32SupportInfo)( VOID );
> DWORD (*pfnSendASPI32Command)( LPSRB );
> BOOL (*pfnGetASPI32Buffer)(PASPI32BUFF);
> BOOL (*pfnFreeASPI32Buffer)(PASPI32BUFF);
> BOOL (*pfnTranslateASPI32Address)(PDWORD,PDWORD);
>
> if( !hinstWNASPI32 )
> {
> MessageBox ("Not loaded");
> }
>
>
> pfnGetASPI32SupportInfo =GetProcAddress ( hinstWNASPI32,
> "GetASPI32SupportInfo" );
>
> Can anyone help me......
>
> Mark
> VBGUYINOVERHEAD
Firstly, Win32 is off-topic, but you're question is still
kind of on-topic because it's to do with the language
itself.
If I'd never used Win32 before, I'd just tell you that that
function wants a pointer to a HINSTANCE, so give it:
pfnGetASPI32SupportInfo = GetProcAddress ( &hinstWNASPI32,
"GetASPI32SupportInfo" );
But... I know the Win32API. LoadLibrary should return a
HMODULE and GetProcAddress should receive a HMODULE. I've
edited your code:
HMODULE hWNASPI32 = LoadLibrary("WNASPI32");
DWORD (*GetASPI32SupportInfo)( VOID );
DWORD (*SendASPI32Command)( LPSRB );
BOOL (*GetASPI32Buffer)(PASPI32BUFF);
BOOL (*FreeASPI32Buffer)(PASPI32BUFF);
BOOL (*TranslateASPI32Address)(PDWORD,PDWORD);
if( !hWNASPI32 )
{
MessageBox("Not loaded");
//Don't forget to quit!
}
GetASPI32SupportInfo = GetProcAddress ( hWNASPI32,
"GetASPI32SupportInfo" );
if ( !hWNASPI32)
{
MessageBox("No such function or error");
//Don't forget to quit!
}
There's no need for the prefixes on the function pointer
names, as they can be used exactly like functions:
GetASPI32SuppportInfo(BLAH);
BTW, are you sure you need to load the dynamically? Why not
use static linkage, as in how you used LoadLibrary.
-JKop
- Next message: JKop: "Re: :: before function calls"
- Previous message: Ireneusz SZCZESNIAK: "Re: overhead of using std::sort"
- In reply to: Intermouse: "Error message getting addresses."
- Next in thread: JKop: "Re: Error message getting addresses."
- Reply: JKop: "Re: Error message getting addresses."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|