Code C2664
Jan 16, 2016 at 10:30pm UTC
I am getting the error HMODULE LoadLibraryW(LPCWSTR)': connot convert argument 1 from 'const char [10]' to LPCWSTR' and argument of type "const char *" is incompatible with parameter of type "LPCWSTR"
Can anyone help me?
1 2
typedef MMRESULT(__stdcall *timebeginperiod) (UINT Period);
timebeginperiod TimeBeginPeriod = (timebeginperiod)GetProcAddress(LoadLibrary("winmm.dll" ), "timeBeginPeriod" );
Jan 16, 2016 at 11:51pm UTC
1 2 3 4 5 6
typedef MMRESULT(__stdcall *timebeginperiod) (UINT Period);
// timebeginperiod TimeBeginPeriod = (timebeginperiod)GetProcAddress(LoadLibrary("winmm.dll"), "timeBeginPeriod");
// use the narrow character versions
timebeginperiod TimeBeginPeriod = (timebeginperiod) GetProcAddressA ( LoadLibraryA ( "winmm.dll" ), "timeBeginPeriod" );
Jan 17, 2016 at 1:06am UTC
Thanks, it worked.
Jan 17, 2016 at 1:13am UTC
Also can you help me with this?
I'm getting this error:
'TimeBeginPeriod': redefinition; multiple initialization
timebeginperiod TimeBeginPeriod = (timebeginperiod)GetProcAddress(LoadLibraryA("winmm.dll" ), "timeBeginPeriod" );
Jan 17, 2016 at 1:29am UTC
Missing closing parenthesis.
1 2 3
// timebeginperiod TimeBeginPeriod = (timebeginperiod)GetProcAddress(LoadLibraryA("winmm.dll"), "timeBeginPeriod");
timebeginperiod TimeBeginPeriod = (timebeginperiod)GetProcAddressA (LoadLibraryA("winmm.dll" ), "timeBeginPeriod" ) ) ;
Prefer to do this in multiple steps, with validation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
const auto lib = LoadLibraryA( "winmm.dll" ) ;
if (lib)
{
// avoid two names that differ only in case
const timebeginperiod pfn_time_begin_period = (timebeginperiod)GetProcAddressA( "timeBeginPeriod" ) ;
if ( pfn_time_begin_period )
{
// use pfn_time_begin_period
}
else std::cerr << "could not find exported symbol\n" ;
}
else std::cerr << "failed to load library\n" ;
Topic archived. No new replies allowed.