CallDll32 funny

CallDll32 funny

Postby peterk » Wed Oct 18, 2006 5:16 am

Hi Antonio

I have a Fwh and xHb aplication using latest Sept/Oct2006 Fw28/xHb
This app call the tMutex.prg class Create method below. The tMutex create method calls CallDLL32(.....). In my application when CallDLL32 is called, i get a pop up msgalert "CallDll32", with a title of "calldll.c". I have tracked this down to \fwh\source\winapi\calldll.c which contains
#ifdef __BORLANDC__
..........
#else
CLIPPER CALLDLL32( PARAMS )
{
#ifndef UNICODE
MessageBox( 0, "CallDll32", "CallDll.c", 0 );
#else
MessageBox( 0, L"CallDll32", L"CallDll.c", 0 );
#endif
}

It seems the above CLIPPER CALLDLL32 is being called in error?
In addition, if I ignore the above msgalert, in the line of code below (::hMutex := CallDLL32(...) is set to an array (in stead of a numeric handle), the 2nd element of which is the correct hMutex handle

If I move tMutex.prg to earlier in my xbp link script, the problem is resolved, but that is an unsatisfactory solution

Can you think what might be causing this?
Thanks
Peter




*********************
Method Create( sMutexAttr, lInitialOwner, cName ) Class TMutex

Local hDLL := LoadLib32( iKERNEL )
Local cFarProc, cFunc := "CreateMutexA", cBuffer := Nil

Default lInitialOwner := .F., cName := "FiveWin App"

If ValType( sMutexAttr ) == "O" .and. ;
Upper( sMutexAttr:className() ) == "TSTRUCT"
cBuffer := sMutexAttr:cBuffer
Endif

::cName := cName

If Abs( hDLL ) > 32 /*LPSTR*/ // LPSTR fails under 32bits!
cFarProc := GetProc32( hDLL, cFunc, iASPASCAL, LONG, LONG, LONG, STRING )
::hMutex := CallDLL32( cFarProc, ;
If( cBuffer # Nil, @cBuffer, cBuffer ), ; // lpMutexAttributes, security descriptor structure or nil
Bool2Int( lInitialOwner ), ; // bInitialOwner, initial owner
cName + Chr(0) ) // lpName, object name
FreeLib32( hDLL )
If cBuffer # Nil
sMutexAttr:cBuffer := cBuffer
Endif

Else
::Failed( hDLL, cFunc )
Endif

Return Self
*********************
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Wed Oct 18, 2006 6:30 am

Peter,

In 32 bits you have to use CallDLL() and GetProcAddress().

The functions you are using are just for 16 bits, to access 32 bits ones.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Wed Oct 18, 2006 9:36 am

Thank you

I now see that tMutex.prg does have the following at the bottom of the tMutex.prg (see end of mail)

So that would mean the fwh calldll.c function 'CLIPPER CALLDLL32( PARAMS )' is being called instead of the 'Function CallDLL32' below (in tMutex).

This should only happen if calldll.c (in FiveHcm.lib) is linked in before tMutex.prg. I am using xBuildW.exe which links FiveHcm.lib in automatically - I will have to investigate further



****************
#ifdef __HARBOUR__
Function LoadLib32( cDll )
Return LoadLibrary( cDll )

Function FreeLib32( hDll )
Return FreeLibrary( hDll )

Function GetProc32( hDLL, cFunc, lType, nRetType, nPType1, nPType2, nPType3, nPType4, nPType5, nPType6, nPType7, nPType8, nPType9, nPType10 )
Return GetProcAddress( hDLL, cFunc, lType, nRetType, nPType1, nPType2, nPType3, nPType4, nPType5, nPType6, nPType7, nPType8, nPType9, nPType10 )

Function CallDLL32( cFarProc, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6, uParam7, uParam8, uParam9, uParam10 )
Return CallDLL( cFarProc, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6, uParam7, uParam8, uParam9, uParam10 )
#endif
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Wed Oct 18, 2006 10:20 am

Peter,

Better do a search & replace for those functions names in TMutex source code instead of using those wrappers.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 72 guests