 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
nonov Guest
|
Posted: Sun Jul 06, 2008 11:54 am Post subject: Dllcall : difference between type* / typeP and &arg? |
|
|
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
|
Posted: Sun Jul 06, 2008 7:49 pm Post subject: |
|
|
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.
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun Jul 06, 2008 7:52 pm Post subject: |
|
|
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 , correct me if I'm wrong).
Did you test swapping/changing them? |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun Jul 06, 2008 7:53 pm Post subject: |
|
|
SKAN beat me to it  |
|
| Back to top |
|
 |
nonov Guest
|
Posted: Sun Jul 06, 2008 8:05 pm Post subject: |
|
|
COOL! ... ...
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|