Gibt den Namen oder die Schnittstelleninformation eines Objekts zurück.
ObjName ( $Objectvariable [, Flag = 1] )
$Objectvariable | Eine Variable die das Objekt enthält dessen Namen man abrufen möchte |
Flag | [optional] $OBJ_NAME (1) = (Standard) Name des Objekts $OBJ_STRING (2) = Beschreibung des (Dokument) Objekts $OBJ_PROGID (3) = Die ProgID des Objekts $OBJ_FILE (4) = Die Datei, mit welcher das Objekt in der Registry verknüpft ist. $OBJ_MODULE (5) = Name des Moduls, in welchem das Objekt läuft (Windows XP und höher). Marshaller für Objekte, welche nicht aus einem Modul aufgerufen werden. $OBJ_CLSID (6) = CLSID der Objekt-Co-Klasse $OBJ_IID (7) = IID der Objektschnittstelle Die Konstanten sind in "AutoItConstants.au3" definiert. |
Erfolg: | Einen den Namen repräsentierenden String |
Fehler: | "" und setzt das @error Flag auf ungleich null. |
Nicht alle Objekte unterstützen die Flags (Bitschalter) 2 bis 7. In diesen Fällen stets @error abfragen.
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
Local $oInternet = ObjCreate("InternetExplorer.Application")
$oInternet.Navigate("http://www.google.com") ; Öffnet eine Webseite, die ein Formular beinhaltet
Sleep(4000) ; Gibt der Seite Zeit zu laden
Local $oDoc = $oInternet.Document ; Zu testendes Beispielobjekt
Local $oForm = $oDoc.Forms(0) ; Zu testendes Beispielobjekt
MsgBox(0, "", "Interface-Name von $oInternet ist: " & ObjName($oInternet) & @CRLF & _
"Objekt-Name von $oInternet ist: " & ObjName($oInternet, $OBJ_STRING) & @CRLF & _
"Interface-Name von $oDoc ist: " & ObjName($oDoc) & @CRLF & _
"Objekt-Name von $oDoc ist: " & ObjName($oDoc, $OBJ_STRING) & @CRLF & _
"Interface-Name von $oForm ist: " & ObjName($oForm) & @CRLF & _
"Objekt-Name von $oForm ist: " & ObjName($oForm, $OBJ_STRING))
$oInternet.Quit()
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
Local $oObj = ObjCreate("InternetExplorer.Application")
ObjName_FlagsValue($oObj)
Func ObjName_FlagsValue(ByRef $oObj)
Local $sInfo = ''
$sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF
; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases.
$sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
$sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
$sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
$sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
$sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
$sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID)
If @error Then $sInfo &= '@error = ' & @error
$sInfo &= @CRLF & @CRLF
MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo)
EndFunc ;==>ObjName_FlagsValue