Jump to content
Sign in to follow this  
Sokko

DLLCall and Windows API questions

Recommended Posts

Sokko

I'm not very learned in the ways of DLL calling, so I have a few questions for the experts here.

1) If a DLL function accepts a pointer as a parameter that, after the function returns, will point to some return value, how do you handle that? Structs?

2) What happens if you need a pointer inside a struct? MSDN always says you need a "pointer to a string" or a "pointer to an array" instead of an actual string or array. Does AutoIt handle this automatically?

3) How do you get a string into a struct, anyway? What about Unicode strings? (for example the "PCWSTR" type, which apparently is a pointer to a Unicode string)

4) What should you do if a piece of a struct is a "union{...}" of two different types, and the function expects it to be one type or the other based on some other parameter? Do you just use the single type that matches the way you're using it?

5) If you don't want or know how to use a callback function, what types/values should be used in a struct for a "pointer to a callback function" and a "pointer to application-defined reference data"?

Answers and/or explanations for any of these questions are much appreciated. Thanks!

Share this post


Link to post
Share on other sites
piccaso

look into this library.

PaulAI already translated many API's

to 5:

The type for a callback would be "ptr" but autoit doesent support callbacks.

There is no simple explanation for DllCalling but there are many examples on this forum.


CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites
Richard Robertson

That is a nice library. If only Microsoft could be more efficient too. With Jon on the Microsoft team now though, will AutoIt become a Windows Professional version option?

Share this post


Link to post
Share on other sites
Sokko

Thanks for that library, Piccaso, but unfortunately it doesn't contain any of the functions I'm looking at (most of them are new to Vista, which probably explains a lot).

Share this post


Link to post
Share on other sites
Sokko

The one that initially prompted me to make this post was TaskDialogIndirect. All five things I asked about are somehow involved in this function. (I am also interested in the functions that deal with NTFS transactions, but one thing at a time)

Edited by Sokko

Share this post


Link to post
Share on other sites
Richard Robertson

If you give us the function declarations, we can translate them with maybe a little extra info such as struct declarations.

Eck, you posted a minute before me. I'll get to work translating.

Edited by Mr Icekirby

Share this post


Link to post
Share on other sites
Richard Robertson

Well, I took a look and I don't know how to translate unions into AutoIt. I also never looked into the callbacks so I can't help you there either. I would probably write a C++ dll with a much simpler function that loads the parameters into the struct.

Share this post


Link to post
Share on other sites
Sokko

Ah, I see. Going on what Valik said there, it looks like if both members of the union are the same size, you can just use whichever one you want. At least, I assume that a pointer and a handle would both be "int" (see hMainIcon and pszMainIcon).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×