Jump to content

Passing string to dll as a void *?


Recommended Posts

Hi All;

How can pass the string data to my dll function which is like below;

DLLDIR BOOL FSUIPC_WriteAndProcess(DWORD dwOffset, DWORD dwSize, void *pSrce, DWORD *pdwResult);

I want to pass string data to void *pSrce. In Calling Library Function Node I have set the pSrce variable Type to "Adapt To Type" and set Data Format to "Handles by Value and Pointers to Handles " but it doesn't work and it gives me Error 1097 occurred at Call Library Function Node in GL.vi error.

How can I pass string to my void* pSrce dll variable?

Best Regards.

Umit Uzun

Link to comment

QUOTE (Umit Uzun @ Apr 29 2009, 09:29 PM)

Hi All;

How can pass the string data to my dll function which is like below;

DLLDIR BOOL FSUIPC_WriteAndProcess(DWORD dwOffset, DWORD dwSize, void *pSrce, DWORD *pdwResult);

I want to pass string data to void *pSrce. In Calling Library Function Node I have set the pSrce variable Type to "Adapt To Type" and set Data Format to "Handles by Value and Pointers to Handles " but it doesn't work and it gives me Error 1097 occurred at Call Library Function Node in GL.vi error.

How can I pass string to my void* pSrce dll variable?

Best Regards.

Umit Uzun

Just declare the entry in the node as a string and Labview will pass a ptr to a string (char * or wchar* depending on your environment I guess). All pointers are just pointers, a char* is the same as a int* etc. It's just in the dll it will treat it differently.

Link to comment

QUOTE (stevea1973 @ May 3 2009, 04:40 AM)

Just declare the entry in the node as a string and Labview will pass a ptr to a string (char * or wchar* depending on your environment I guess). All pointers are just pointers, a char* is the same as a int* etc. It's just in the dll it will treat it differently.

That isn't the full truth: Pointers are basically addresses but they differ in an important detail, the data type they point to.

char* points to char, int* to int and so on. You can't do much with a void* unless you know to what type it points:

The data type determines the layout and size of the referenced memory.

In C void pointers are used to bypass the type checking of the compiler. Your DLL internally "knows" what type it expects

and treats your pointer that way. If you want to pass a C string you first have to know what kind of string it expects:

plain ASCII which always is char*, or Unicode which is unsigned short* on win32 platforms.

If it expects char* you're lucky but if it expects Unicode you have to do further conversion before you can pass the string.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.