From WikiChip
Editing mirc/component object model
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 26: | Line 26: | ||
<source lang="mIRC">/comclose <hName></source> | <source lang="mIRC">/comclose <hName></source> | ||
− | Before we can go on to use the COM object, we have to confirm a successful connection has been established. The | + | Before we can go on to use the COM object, we have to confirm a successful connection has been established. The $comerr will return 1 if the connection has failed, 0 otherwise. |
=== Connecting/Disconnecting Example === | === Connecting/Disconnecting Example === | ||
Line 127: | Line 127: | ||
== Invoking members == | == Invoking members == | ||
− | To invoke a member of a COM object, we use the | + | To invoke a member of a COM object, we use the $com identifier using the following sytax: |
<source lang="mIRC">;member with no arguments | <source lang="mIRC">;member with no arguments | ||
Line 147: | Line 147: | ||
#The argument is a string - data type is bstr | #The argument is a string - data type is bstr | ||
− | Using the information above we can write our | + | Using the information above we can write our $com identifier to invoke that method: |
<source lang="mIRC">;Exec is the Object's member we are invoking | <source lang="mIRC">;Exec is the Object's member we are invoking | ||
Line 155: | Line 155: | ||
$com(shellCOM, Exec, 1, bstr, calc)</source> | $com(shellCOM, Exec, 1, bstr, calc)</source> | ||
− | + | $com will return either 1 if the invocation of the Object's member was successful, 0 otherwise. It is a good practice to check if the invocation was a success. Below is the complete script: | |
<source lang="mIRC">alias openCalc { | <source lang="mIRC">alias openCalc { | ||
Line 172: | Line 172: | ||
== Value of A Property / Enumerated Collection == | == Value of A Property / Enumerated Collection == | ||
− | Retrieving a value from an enumerated collection or a property (like a variable) can be done using the | + | Retrieving a value from an enumerated collection or a property (like a variable) can be done using the $comval identifier following this syntax: |
<source lang="mIRC">$comval(<hName>, <N>, <member>)</source> | <source lang="mIRC">$comval(<hName>, <N>, <member>)</source> | ||
Line 178: | Line 178: | ||
== Retrieving return values == | == Retrieving return values == | ||
− | Recall from before, if we use invocation method value 2, we are indicating we want a return value. Well, to retrieve that value we can use the | + | Recall from before, if we use invocation method value 2, we are indicating we want a return value. Well, to retrieve that value we can use the $com identifier in a different way: |
<source lang="mIRC">var %value = $com(<hName>).result</source> | <source lang="mIRC">var %value = $com(<hName>).result</source> | ||
Line 260: | Line 260: | ||
}</source> | }</source> | ||
− | Since we are now at the Win32_Porocessor object, all we have to do is retrieve the values. Recall from above that we can do that using the | + | Since we are now at the Win32_Porocessor object, all we have to do is retrieve the values. Recall from above that we can do that using the $comval identifier: |
<source lang="mIRC">$comval(Win32_Processor, 1, <property>)</source> | <source lang="mIRC">$comval(Win32_Processor, 1, <property>)</source> | ||
Line 294: | Line 294: | ||
== Other useful properties == | == Other useful properties == | ||
− | The | + | The $com identifier has a few other useful properties: |
{| class="wikitable" | {| class="wikitable" | ||
Line 308: | Line 308: | ||
|progid || object's name | |progid || object's name | ||
|- | |- | ||
− | |dispatch/unknown || return | + | |dispatch/unknown || return $true or $null if a pointer to this object exists |
|} | |} | ||