Declare Function type

Hi, I need to convert this to XOJO code:

wchar_t** listofitems;
int counts;
int ret1;
ret1=getdatalist(&listofitems, &counts);

But this doesn’t work!!

soft Declare Function getdatalist Lib “XXXXXXXXXX” (lista as ptr,byref count as int32) as Integer

dim nom2 as new MemoryBlock(2550)
dim total2 as int32
dim k as int
dim valor as string

k=getdatalist(nom2,total2)

valor=nom2

total2 is right, but nom2 or valor has garbage values.

Any help? thanks.

What library? “XXXXXXXXXX” is not very helpful.

It would help greatly to explain much more. Is it code for Windows to access a DLL methods ? Is it a way to access the framework ? In OS X, Windows, Linux ?

The Lib “XXXXXXXXXX” is IMHO borderline rude. What is so sensitive about it you felt the need to obfuscate it ?

As it stands, you do not give enough information to receive any assistance.

[quote=289278:@Jose Navarro]dim nom2 as new MemoryBlock(2550)
dim total2 as int32
dim k as int
dim valor as string

k=getdatalist(nom2,total2)[/quote]
Some thoughts:

  • Make sure your endianess is correct.
  • Make sure that you’re reading the correct data type, a int32 is different to a Uint32, which is different to a integer (especially when you build for 64-Bit).
  • It seems a bit odd that you have to allocate a block of memory before you get the size.
  • I’m guessing wchar_t is a windows data type and I’m guessing it’s an array of pointers, so you may need to resolve each entry.

A wchar_t* is like a normal char*, except that it’s wide. On Windows, this means 2 bytes per character and on OS X/Linux it means 4 bytes per character. This maps directly to Xojo’s WString data type.

To have a wchar_t** one can make the parameter type be a ByRef WString.

Thanks Joe.