give pointer in dll
give pointer in dll
how may I give pointer as parameter to function in DLL
p1,p2 - pinter
err:=_OWersja(p1,p2)
...
...
???
declare DLL_TYPE_BYTE _OWersja(DLL_TYPE_LPCSTR CFILE1, DLL_TYPE_LPCSTR CFILE2) in WinIP.Dll
p1,p2 - pinter
err:=_OWersja(p1,p2)
...
...
???
declare DLL_TYPE_BYTE _OWersja(DLL_TYPE_LPCSTR CFILE1, DLL_TYPE_LPCSTR CFILE2) in WinIP.Dll
best regards
kajot
kajot
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Kajot,
strings are automatically managed as pointers (their addresses is supplied, not their content).
For numbers you have to supply them by reference using @
If the function is not working as expected, its a good idea to access it using C code instead of using DLL FUNCTION, just to locate where the problem may come from. Just implement a C wrapper using pragma BEGINDUMP ... ENDDUMP. There are many examples in these forums
strings are automatically managed as pointers (their addresses is supplied, not their content).
For numbers you have to supply them by reference using @
If the function is not working as expected, its a good idea to access it using C code instead of using DLL FUNCTION, just to locate where the problem may come from. Just implement a C wrapper using pragma BEGINDUMP ... ENDDUMP. There are many examples in these forums
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Here you have a working example that shows how strings are managed as pointers:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local cIn := "Hello world!"
local cOut := Space( Len( cIn ) )
Test( cIn, cOut )
MsgInfo( cOut )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
HB_FUNC( TEST )
{
strcpy( hb_parc( 2 ), hb_parc( 1 ) );
strupr( hb_parc( 2 ) );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
I am usingv
xHarbour Compiler build 1.0.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
xHarbour Compiler build 1.0.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
best regards
kajot
kajot
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Kajot,
Then add this code to the PRG:
Then add this code to the PRG:
Code: Select all | Expand
#pragma BEGINDUMP
#include "string.h"
#include "ctype.h"
char * strupr( char * string )
{
char c, * p = string;
while( ( c = * p ) != '\0' )
* ( p++ ) = _toupper( c );
return string;
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 42511
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Try this one:
char _toupper( char );
char _toupper( char );
Code: Select all | Expand
#pragma BEGINDUMP
#include "string.h"
#include "ctype.h"
char _toupper( char );
char * strupr( char * string )
{
char c, * p = string;
while( ( c = * p ) != '\0' )
* ( p++ ) = _toupper( c );
return string;
}
#pragma ENDDUMP
Last edited by Antonio Linares on Sun Jul 27, 2008 9:09 am, edited 1 time in total.