AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dllcall : difference between type* / typeP and &arg?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
nonov
Guest





PostPosted: Sun Jul 06, 2008 11:54 am    Post subject: Dllcall : difference between type* / typeP and &arg? Reply with quote

i saw this code from this post
Code:
DllCall( "psapi.dll\EnumProcesses", "uint", &pid_list, "uint", pid_list_size, "uint*", pid_list_actual )

and MSDN says about those parameters
MSDN wrote:
pProcessIds [out] A pointer to an array that receives the list of process identifiers.
cb [in] The size of the pProcessIds array, in bytes.
pBytesReturned [out] The number of bytes returned in the pProcessIds array.

below are what i've got from help file
Quote:
Address (&) : &MyVar retrieves the address of MyVar's contents in memory.
* or P (suffix) : Append an asterisk (with optional preceding space) to any of the above types to cause the address of the argument to be passed rather than the value itself

i'm not seeing any difference on those explanations. as far as i've understand it, those are equivalent. (correct me if i got it wrong) i just don't understand that why he used & for 1st parameter but * for 3rd parameter. if assumed those are same. is there something that i don't know or misunderstood? if so could anyone enlighten me please?
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Sun Jul 06, 2008 7:49 pm    Post subject: Reply with quote

I have been confused too..
..but with experience I can tell you that UInt, &Var needs a prior VarSetCapacity() but UIntP, Var does not need one.

Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun Jul 06, 2008 7:52 pm    Post subject: Reply with quote

In the first (&), the variable is already initialized, with a certain size (VarSetCapacity), the second get's created (*/P), but you are right, they are essentially the same (AFAIK, I'm no expert), but are used differently based on fixed/growing/unknown variable size, and performance considerations.

Your example shows that the amount of names of running processes can be big, so, the variable is created and sized beforehand. The count of the running processes however is "small" and of a fixed size, so "safe" (I sure hope I'm not writing b*ll here Shocked Wink , correct me if I'm wrong).

Did you test swapping/changing them?
Back to top
n-l-i-d
Guest





PostPosted: Sun Jul 06, 2008 7:53 pm    Post subject: Reply with quote

SKAN beat me to it Wink
Back to top
nonov
Guest





PostPosted: Sun Jul 06, 2008 8:05 pm    Post subject: Reply with quote

COOL! Smile ... Very Happy ... Laughing

Thank you very much SKAN and daonlyfreez.
it was the only equivocal explanation that i've met in the help. your explanation is much clear. i think your explanation should be added on help. Thanks a bunch!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group