Error message getting addresses.

I

Intermouse

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
 
V

Victor Bazarov

Intermouse said:
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......

LoadLibrary returns HMODULE and not HINSTANCE. GetProcAddress needs
HMODULE as its first argument. Perhaps that's what you need to give
it to keep it happy...

V
 
J

JKop

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
 
J

JKop

if ( !hWNASPI32)
{
MessageBox("No such function or error");

//Don't forget to quit!
}

The second one should've been

if (!GetASPI32SupportInfo)
BTW, are you sure you need to load the dynamically? Why not
use static linkage, as in how you used LoadLibrary.

TYPO

BTW, are you sure you need to load the library and function
dynamically? Why not use static linkage, as in how you used
LoadLibrary?

-JKop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,479
Latest member
JaysonK723

Latest Threads

Top