Solved Binary data from external DLL

General discussion forum about all things Team Developer 6.x
kolinek
Czech Republic
Posts: 3
Joined: 26 May 2017, 09:27
Location: Czech

Binary data from external DLL

Post by kolinek » 26 May 2017, 11:06

Hi,
I want set binary data (bmp picture) from extenal function like this
int getPic ( char *sBuffer, INT *nDataLength )
to picture.

Code: Select all

Function: getPic
	Description:
	Export Ordinal: 1
	Returns
		Number: INT
	Parameters
		Receive String: LPSTR
		Receive Number: LPINT
How sent data in sBuffer to picture ?
It is possible without saving data to file in external function and load data to picture from file ?

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 118
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Binary data from external DLL

Post by Igor Ivanovic » 29 May 2017, 14:53

You can load the picture from a file, resource, string etc with VisPicLoad, and then set it to the picture with SalPicSetHandle.
Igor Ivanovic
Image

kolinek
Czech Republic
Posts: 3
Joined: 26 May 2017, 09:27
Location: Czech

Re: Binary data from external DLL

Post by kolinek » 01 Jun 2017, 07:39

Problem is, that binary data in sBuffer TD transfers to unicode and terminate on first 0 byte.
I suppose, there is only possibility, that DLL save data to file, and TD open file as binary:

If SalFileOpen(hFile, sFileName, OF_Read|OF_Binary)
Call SalSetBufferLength(sBuffer, 1000000)
If SalFileRead(hFile, sBuffer, 1000000)>0
Set bOk= SalPicSetString ( pic1, PIC_FormatObject, sBuffer )

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 400
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Binary data from external DLL

Post by Dave Rabelink » 01 Jun 2017, 07:53

Then you will have to change the external function parameter definition:

Code: Select all

Function: getPic
Description:
Export Ordinal: 1
Returns
	Number: INT
Parameters
	Receive String: LPVOID
	Receive Number: LPINT
Change LPSTR to LPVOID.

Indeed, TD will convert a LPSTR (which TD assumes being a ANSI string) to UNICODE automatically.
Using LPVOID instructs TD not to convert the data and pass it into the string as-is (being binary).

So your code would look like:

Code: Select all

Call SalSetBufferLength( sBuffer, nMaxSize )
Call getPic( sBuffer, nSize )
Call SalPicSetString( pic1, PIC_FormatBitmap, sBuffer )
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

kolinek
Czech Republic
Posts: 3
Joined: 26 May 2017, 09:27
Location: Czech

Re: Binary data from external DLL

Post by kolinek » 05 Jun 2017, 12:34

Thanks, LPVOID works properly.

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests