Use external function lstrcpyn from Kernel32.dll

Discussion forum about all things SqlBase.
MariaA

Use external function lstrcpyn from Kernel32.dll

Post by MariaA » 17 Jan 2016, 12:37

Hi,
I want to use external function lstrcpyn() from Kernel32.dll in an stored procedure in SQLBase 11.7.

The function call works fine in Team Developer (see attached samples) but I can't get it to work as an SP in SQLBase.
If I use this declaration:

CREATE EXTERNAL FUNCTION "lstrcpyn" PARAMETERS (LPSTR, LPSTR,LONG) RETURNS (BOOL) LIBRARY Kernel32.dll CALLSTYLE STDCALL EXECUTE IN SEPARATE PROCESS
or
CREATE EXTERNAL FUNCTION "lstrcpynA" PARAMETERS (LPSTR, LPSTR,LONG) RETURNS (BOOL) LIBRARY Kernel32.dll CALLSTYLE STDCALL EXECUTE IN SEPARATE PROCESS;
my input parameter is only copied to the output paramter, without bothering to chop the left most characters specified.

This declaration does not work at all since SQLBase can't use LPWSTR as parameters:
CREATE EXTERNAL FUNCTION "lstrcpynW" PARAMETERS (LPWSTR, LPWSTR,LONG) RETURNS (BOOL) LIBRARY Kernel32.dll CALLSTYLE STDCALL EXECUTE IN SEPARATE PROCESS;

See attached script for testsample.
Best regrads
Maria
You do not have the required permissions to view the files attached to this post.

MariaA

Re: Use external function lstrcpyn from Kernel32.dll

Post by MariaA » 17 Jan 2016, 12:43

Attachements..
You do not have the required permissions to view the files attached to this post.

Mike Vandine

Re: Use external function lstrcpyn from Kernel32.dll

Post by Mike Vandine » 21 Jan 2016, 05:53

Hi Maria,

I will have someone take a look at this.

Best regards,

MIke

Mike Vandine

Re: Use external function lstrcpyn from Kernel32.dll

Post by Mike Vandine » 16 Feb 2016, 04:15

Hi Maria,

Sorry for the late reply.

Hmmmmm. Looking at the internet:

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

There is a big warning: Do Not Use. Consider using StringCchCopy instead. See Remarks.

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Is that helpful at all?

Best regards,

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2364
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Use external function lstrcpyn from Kernel32.dll

Post by Jeff Luther » 18 Feb 2016, 18:35

Maria -- looks like the links Mike pasted didn't quite turn into correct links. Here are the correct links:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
and
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Last edited by Anonymous on 19 Feb 2016, 20:28, edited 1 time in total.
Jeff Luther @ PC Design
Palm Springs, California

Mike Vandine

Re: Use external function lstrcpyn from Kernel32.dll

Post by Mike Vandine » 19 Feb 2016, 00:27

Thanks, Jeff!

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests