Problem with Return Value while calling C function?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BoskeyT
Posts: 2
Joined: Mon Feb 18, 2008 8:06 am

Problem with Return Value while calling C function?

Post by BoskeyT »

Hi All,

I am calling C dll in macro which converts Unicode data to 8 bit encoding data
' Prototype of C function.
' extern "C" int _stdcall Uni2Eni(wchar_t * uni, unsigned char * eni, int size)

'Here is the function where creating alias of C function using C dll(capi.dll)
' ByVal Uni As String ( Its a Unicode string)
‘ByVal eni As String ( its a Non_Unicode string)
Declare Function UNI2Eni Lib "capi.dll" Alias " Uni2Eni " ( ByVal Uni As String, ByVal eni As String, ByVal iSize As Integer) As Integer

Sub Test
Dim iRet as integer
Dim sEni as String
iRet = UNI2Eni(“क”,sEni,40)
End Sub
On calling this function it return iRet =1 which shows conversion has been successful but the value returned in sEni is showing blank .
Is it the problem with data type or something else?
Please anyone can help me?.
I have used the same dll in VBA its gives right output.
I am using open office 2.0.
ms777
Volunteer
Posts: 176
Joined: Mon Oct 08, 2007 1:33 am

Re: Problem with Return Value while calling C function?

Post by ms777 »

try replacing

Code: Select all

Declare Function UNI2Eni Lib "capi.dll" Alias " Uni2Eni " ( ByVal Uni As String, ByVal eni As String, ByVal iSize As Integer) As Integer 
by

Code: Select all

Declare Function UNI2Eni Lib "capi.dll" Alias " Uni2Eni " ( ByRef Uni As String, ByRef eni As String, ByVal iSize As Integer) As Integer 
Post Reply