andrewjfox Posted December 12, 2011 Share Posted December 12, 2011 Hi, From one post straight on to another... Is it possible to mimic a structure of different data types to pass to an extern function. I'm trying to call SendInput from user32.dll. It expects a ptr to an array of structures. I have been able to break the structure down to basic parts that DF will understand, but they are a mix of word, dword, ulong. uint SendInput(uint, LPINPUT, int) LPINPUT is ptr to array of INPUT structures // INPUT structure { DWORD KEYBDINPUT } // KEYBDINPUT structure { WORD WORD DWORD DWORD ULONG } I can match up the Windows types to basic types that DF will understand, but can I specify a type in the extern function prototype that DF will understand, but will also hold the structure? Can I prototype as an array of ints and then manually encode the array with data? I note that you somethimes recommend the use of wrappers, is this my best option? Regards Andrew Link to comment Share on other sites More sharing options...
AzeoTech Posted December 12, 2011 Share Posted December 12, 2011 It can be done, but a wrapper might be easier. You can't change the prototype. The only thing that gets passed is a pointer. The structure you point to doesn't matter to extern(), only the function you are calling. To do this, you'd have to use the To. and From. functions to convert all your values into byte arrays, then concat them into a single byte array and pass a pointer to it to your function (by specifying BYTE[] in the prototype, with the appropriate length inside of the []). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.