Welcome! Log In Create A New Profile


[WD22] ActiveX BSTR variable

Posted by Michael Drechsel 
[WD22] ActiveX BSTR variable
November 09, 2018 06:58PM

I use an activex dll to show PDF Files. The syntax to open the file is

HRESULT OpenDocFromPath([in] BSTR sSrcPath,
[in, defaultvalue(NULL)] ICab* pOpenParams);

I tried everything to fill the BSTR sSrcPath parameter but get errors.

Anybody knows whats the translation from BSTR in windev is ?

regards Michael
Re: [WD22] ActiveX BSTR variable
November 09, 2018 07:45PM
Hi Michael,

did you try to use a UNICODE string or
a Variant ?

Steven Sitas

Edited 1 time(s). Last edit at 11/09/2018 07:56PM by StevenSitas.
Re: [WD22] ActiveX BSTR variable
November 09, 2018 09:17PM

yes, but no chance.

Found this:


But how could I make this in WD ????

regards Michael
Re: [WD22] ActiveX BSTR variable
November 12, 2018 11:37AM
Hi Michael,

the helptalks about a
Pascal string on xxx
where xxxx is your length of the string


looks like the one you need, I would give it a try.

Although I read "String preceded by a byte that specifies the length ". Whereas a BSTR needs 2 bytes which is probably due to the fact that it is UNICODE

Re: [WD22] ActiveX BSTR variable
November 12, 2018 12:38PM
I also found a piece of code using buffers and the Transfer() function and so on.
I tried to 'rewrite' it to you situation and then it looks like this.

It gets a bit more technical and therefore hard(er) to follow if you are not coming from C/C++/C# ….

nSize is int
nTmpInt is 4-byte int
bufApi is Buffer
bufFile is Buffer
sFile is UNICODE string

sFile = "C:\Windev22\Help\WINDEV 22 AAF.pdf" 
bufFile = sFile
nSize = Dimension(nTmpInt)	
nSize += Length(bufFile)	// note: without the terminating null character

// allocate a buffer with the requested size and fill with binary zeros
bufApi = RepeatString(Charact(0), nSize+2) 

// add the size off the buffer as the first 4 bytes

// then add the buffer itself, including a terminating null character
bufFile += CharactUnicode(0)
Transfer(&bufApi + Dimension(nTmpInt),&bufFile,Length(bufFile))


Re: [WD22] ActiveX BSTR variable
November 12, 2018 04:11PM
Hi Arie,

wow, what a reply ! Many thanx.

In the meantime I guess its perhaps a bug in the activex interface.

I tried some other functions which also need BSTR as parameter and voila:

1. AX_Pdf>>CreateNewBlankDoc2("A3",2,90) //works

HRESULT CreateNewBlankDoc2([in] BSTR sPaperSize,
[in] LONG nPagesCount,
[in, defaultvalue(0)] LONG nPageRotation);

2. AX_Pdf>>OpenDocWithDlg("C:\Windows") //works

HRESULT OpenDocWithDlg([in, defaultvalue("")] BSTR sInitialPath,
[in, defaultvalue(0)] VARIANT_BOOL bOnlyPDF,
[in, defaultvalue(0)] VARIANT_BOOL bNoErrorUI);

3. AX_Pdf>>OpenDocFromPath("D:\test.pdf") //Error

HRESULT OpenDocFromPath([in] BSTR sSrcPath,
[in, defaultvalue(NULL)] ICab* pOpenParams);

It seems that I have nothing to do with the strings .... But it could be that I am wrong.

For all interested in this case: The Tracker Software PDF SDK can be found here:


It´s free for testing.

regards Michael

regards Michael

Edited 3 time(s). Last edit at 11/12/2018 04:16PM by Michael Drechsel.
Re: [WD22] ActiveX BSTR variable
November 12, 2018 08:01PM

i gave it a quick try, unfortunately with the same result as you : an error sad smiley

I'm afriad I don't have the time to dig deeper, at the moment. Quite busy here...

I first tried wd22/23 but then the ActiveX cannot be loaded in the first place. Then I remembered an older post where we came to the conclusion that only WD21 worked. Maybe WD and Tracker ActiveX is not a good combination in this case.

Re: [WD22] ActiveX BSTR variable
November 13, 2018 10:31AM
Hi Arie,

It works in WD22 and WD23 (You have just create it in WD21 and update the project)

I´m in contact with the Tracker Software Support:

The PDF Editor is very powerful and we use the standalone Version in our office since many years.

I need a solution, because redlining is not availible in the windev pdf functions and it is nessesary in our system.

regards Michael

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.