Moving Data From VB --> MFC DLL
-
I have a large data strucutre that is used in an embedded C application. I have replicated the strucutre in VC++ and put a class wrapper around it. This data structure contains mostly basic data types. However there are a few fields that are fixed length arrays (char []) as string placeholders. I need to transport this structure to VBA. I have used IDL in order to solve this before. But I was wondering if you guys have any other reccommendations. ? We are using an excel spread sheet as a tag list for our product. I will use this data to generate a binary file that will be used by our embedded software to configure hardware at run-time. Could the VB Gurus please tell me how I can transfer this data to the DLL... what is the best way??? Lets say I store the excel data in a vb data strucute (and use an array of these strucutres). can I pass a pointer to that block of memory to my dll. Can I go in reverse as well? I know there might have to be translation. Im a little stuck here, please help.. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
I have a large data strucutre that is used in an embedded C application. I have replicated the strucutre in VC++ and put a class wrapper around it. This data structure contains mostly basic data types. However there are a few fields that are fixed length arrays (char []) as string placeholders. I need to transport this structure to VBA. I have used IDL in order to solve this before. But I was wondering if you guys have any other reccommendations. ? We are using an excel spread sheet as a tag list for our product. I will use this data to generate a binary file that will be used by our embedded software to configure hardware at run-time. Could the VB Gurus please tell me how I can transfer this data to the DLL... what is the best way??? Lets say I store the excel data in a vb data strucute (and use an array of these strucutres). can I pass a pointer to that block of memory to my dll. Can I go in reverse as well? I know there might have to be translation. Im a little stuck here, please help.. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
You can pass the actual pointer of your vb structure to the C Dll using the ByRef flag which is declared on your parameters of the Public Function...Lib..Alias...(ByRef mystruct as MYSTRUCT) hook in vb. You can then use the pointer to modify the contents in the dll and vb SHOULD be ok with it. However there are problems with it, especially surrounding MODIFICATION of strings in the dll since vb uses BSTR's (a unicode string that can ignore null terminators) and I bet that your dll uses LPSTR's which are non unicode (which is perfectly acceptable). VB should convert them to BSTR's but I have encountered fiddly problems with it that tested my patience :). Alan. "When I left you I was but the learner, now I am the master" - Darth Vader