Umit Uzun Posted April 30, 2009 Report Share Posted April 30, 2009 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 Quote Link to comment
stevea1973 Posted May 4, 2009 Report Share Posted May 4, 2009 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. Quote Link to comment
candidus Posted May 6, 2009 Report Share Posted May 6, 2009 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.