Hi Xavi,
> Ok. I would suggest two things .-
> One is a minor change to remove warnings (attached patch).
Should be fixed now. (Though for me only one of them
gave warning, pls tell if it's still wrong).
> Another: There would fit PRG copy items to avoid change if parameters are not
> passed by reference.
> Sample .-
> ...
> ? "CALLDLL: ", CallDll( GetProcAddress( hDLL, "SHGetFolderPath" ), 0,
> CSIDL_ADMINTOOLS, 0, 0, cData ) // WRONG
> ? "cData: ", cData
> ...
I see what you mean. I don't know the most optimal way
to solve that. This should be fixed in hb_u32par()
and hb_u64par() under HB_WIN_DLL_CTYPE_CHAR_PTR.
Currently hb_itemGetStr*() don't always duplicate
the string, which causes the problem. I'd need the
simplest way to make the conversion and force
duplication. Przemek, if you see this, what do you
suggest?
>> I was also thinking to create a way to describe and pass
>> C level function skeletons as string to HB_DLLCALL(),
>> which could then decide about the precise details, make
>> necessary conversions, etc.
>>
>> F.e.:
>> HB_DLLCALL( h, "__cdecl _int64 AnyCall( int, long, double )", nPar1,
>> nPar2, nPar3 )
>> or something Windows specific (since we're in hbwin lib yet):
>> HB_DLLCALL( h, "WINAPI DWORD SetSomething( LPTCSTR )", cHarbourString )
>>
>> Such thing could make .dll calls very user-friendly.
>> It's over my C knowledge, but maybe someone will be able
>> to implement in the future.
>
> I think that Przemek could say something. :)
> [ It's a parser to C language with examples of rules on C interpreters. ]
> Maybe I've spent the finish line and only need to interpret some key words in
> the string.
> But this don't substract that currently, it's very functional IMO.
Actually, such function could be written as .prg
code by anyone. Now the low-level logic is there,
so all such function needs to do is parse the
string, optionally load .dll look for function,
and convert string tokens (callconv, types) to
WIN_DLLCALL() parameters:
RETURN WIN_DLLCALL( { nCallConv, nRetType, [bUNICODE], nPar1Type, ...,
nParnType }, pFunction, xPar1, ..., xParn } )
Where numeric constants can be found in hbwin.ch.
This could be the end result:
WIN_DLLCALLSTR( "WINAPI DWORD Hello( WORD, DWORD ) IN winapi.dll", 10, 100 )
-> 50
The string syntax can be C, VB or CAVO or anything else
for that matter, it could even support multiple syntaxes.
Brdgs,
Viktor
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour