Leaderboard
Popular Content
Showing content with the highest reputation on 01/10/2014 in all areas
-
Since Jos banned you for 5 days yesterday it appears that since being banned you have been PMing other members asking for help and annoying them on "soshul meedja" as well. As you obviously have no intention of behaving in a suitable manner I see no point in you remaining part of this community - permanently banned.2 points
-
Last updated 9/10/21 * Image may not represent current product Features Simple Integrated countermeasures against file and memory analysis based decompilers. Add basic types of resources into the interpreter or other types as raw data. Define multiple programs to execute pre and post build. Create and include pe version information. User defined patches that can be implemented globally on the interpreter and compiler or selectively. Handles its own basic macro's as well as environment variables in most fields for easier path finding. Drag and drop configs (script bound or separate) to the input edit box or to the icon to load them. Configuration settings can be copied to the clipboard or saved as config files or Au3 scripts. Settings can now be saved directly to an AutoIt3 script. Subsystem independant, can act as a gui or console tool. And much more. See next post for update information. A3C_97.16b.7z A3C_98_18_b.zip1 point
-
[this post are in deletion pending] User: See my signature for more info! AutoIT3 Virtualization UDF Virtual File, Virtual Registry, Dll Virtualization, ActiveX Virtualization Enable you to store file virtually in memory.Virtualizing program module like Dll, ActiveX Component and Etc. You can try virtualize Flash ActiveX and Flash Movie too. Ha.. Ha.. 3x At least you does not need MemoryDllCall again just use. DllOpen, DllCall, DllClose and Etc. There for example I create ActiveX component TColorBox in Delphi and virtualize it in AutoIt3. Attach Virtual File to another process Execute dot net application from virtual file and or embedded file Function ; Exports ; Virtual_ActiveXA ; Virtual_ActiveXW ; Virtual_DebugLog ; Virtual_AttachToProcess ; Virtual_DetachFromProcess ; Virtual_DirCreateA ; Virtual_DirCreateW ; Virtual_ExecuteDotNetA ; Virtual_ExecuteDotNetW ; Virtual_FileA ; Virtual_FileW ; Virtual_FileDeleteA ; Virtual_FileDeleteW ; Virtual_IsVirtualFileA ; Virtual_IsVirtualFileW ; Virtual_IsVirtualProcess ; Virtual_LibraryA ; Virtual_LibraryW ; Virtual_LogFileA ; Virtual_LogFileW ; Virtual_Option ; Virtual_ProcessOption ; Virtual_RegDelete ; Virtual_RegWrite ; Virtual_RegKeysEnumVirtualA ; Virtual_RegKeysEnumVirtualW ; Virtual_RegisterServer ; Virtual_UnregisterServer ; Virtual_VirtualGate ; Virtual_VirtualChild ; Virtual_VirtualDeamon Note Don't need call Virtual_RegisterServer if you using Virtual_ActiveXA and or Virtual_ActiveXW function Screenshot Archive Choose which one server you will download the archive. autoit3vt.zip (www.autoitscript.com) Sample.LaunchEmbeddedExe^.zip Last Archive History #03 Attached File autoit3vt.zip 881.71K 95 downloads #02 Attached File autoit3vt.zip 830.67K 11 downloads #01 Attached File autoit3vt.zip 538.92K 27 downloads Yeah, you right Melba!I modified the AutoIT3 executable. Oh so it break the EULA. Now I have been updated the UDF. No executable again, just pure AutoIT3 script. Simple and Complex Implementation - Execute Executable or Dot Net App from embedded script. - Call Embedded Dynamic Link Library with native function DllOpen, DllCall, DllClose and etc (without MemoryDLLCall). - Using two or more different ActiveX version in one machine. - ActiveX sure have incompatible for some upward or backward you can by fix with virtualization. - Also automatically using ActiveX without installing it on machine and or without touching the real Windows Registry. - Good starting point to create application like PortableApps which can run on ROM like CD, DVD or Blueray Disk and or locked memory/USB Disk. - Analyze program by starting it in virtualization. What file and registry activity of program. Possibly for malware ana- lysis. - There wide range implementation of this. Search by ur'self. - Et catera. Take a look for my other post >Graphical AutoIt3 Control >GTK+ Framework | Widgets1 point
-
Exe server (IDispatch Call)
argumentum reacted to wolf9228 for a topic
Exe server (IDispatch Call) http://msdn.microsoft.com/en-us/library/windows/desktop/ms683835(v=vs.85).aspx ;There are two main types of servers, in-process and out-of-process. In-process servers are implemented in a ;dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process ;servers can reside either on the local computer or on a remote computer. In addition, COM provides a mechanism that ;allows an in-process server (a DLL) to run in a surrogate EXE process to gain the advantage of being able to run the ;process on a remote computer. For more information, see DLL Surrogates. All project files Exe_Server.zip Program.au3 #include "Server32.au3" #include <Array.au3> StartRun() Func ProgramMain() $pDisp = DispatchCServerCreate() $Return = DispCall($pDisp,"long","Server_DataTypeA",$DISPATCH_METHOD,"BYTE",1,"BYTE*",0,"BOOLEAN",2,"BOOLEAN*",0,"SHORT",3, _ "SHORT*",0,"USHORT",4,"USHORT*",0,"WORD",5,"WORD*",0,"INT",6,"INT*",0,"LONG",7,"LONG*",0,"BOOL",True,"BOOL*",0,"UINT",8, _ "UINT*",0,"ULONG",9,"ULONG*",0) _ArrayDisplay($Return,"Server_DataTypeA") $LPARAM_IN = _WinAPI_MakeLong(10,20) $WPARAM_IN = _WinAPI_MakeLong(30,40) $Return = DispCall($pDisp,"long","Server_DataTypeB",$DISPATCH_METHOD,"DWORD",1,"DWORD*",0,"INT64",2,"INT64*",0,"UINT64",3, _ "UINT64*",0,"FLOAT",3.4,"FLOAT*",0,"DOUBLE",5.5,"DOUBLE*",0,"LPARAM",$LPARAM_IN,"LPARAM*",0,"WPARAM",$WPARAM_IN,"WPARAM*",0, _ "VBOOL",8,"VBOOL*",0) _ArrayDisplay($Return,"Server_DataTypeB") $Return = DispCall($pDisp,"long","Server_BSTR",$DISPATCH_METHOD,"BSTR",StrToBstr("BSTR_NI"),"BSTR*",0) $BSTR = $Return[2] _ArrayDisplay($Return,"Server_BSTR") MsgBox(0,"BSTR_OUT",BstrToStr($BSTR)) $Variant = DllStructCreate($tagVariant) DllStructSetData($Variant,"vt",GetDataTypeNu("LONG")) SetUnionOfVariant($Variant,"LONG",333) $Return = DispCall($pDisp,"long","Server_VARIANT",$DISPATCH_METHOD,"VARIANT",DllStructGetPtr($Variant)) _ArrayDisplay($Return,"Server_VARIANT") $BSTR = GetUnionOfVariant($Variant,"ptr") MsgBox(0,"VARIANT_OUT",BstrToStr($BSTR)) $ARRAY = SafeArrayCreate("long",1000) $Return = DispCall($pDisp,"long","Server_ARRAY",$DISPATCH_METHOD,"ARRAY",$ARRAY,"ARRAY*",0) $ARRAY_OUT = $Return[2] MsgBox(0,"ARRAY_OUT",$ARRAY_OUT) _ArrayDisplay($Return,"Server_ARRAY") $DoubleTime = GetDoubleTime(2014,1,7,10,3,20,10,0) $Return = DispCall($pDisp,"long","Server_DATE",$DISPATCH_METHOD,"DATE",$DoubleTime,"DATE*",0) $DATE_OUT = $Return[2] $SystemTime = GetSystemTime($DATE_OUT) _ArrayDisplay($SystemTime,"SystemTime") _ArrayDisplay($Return,"Server_DATE") $Return = DispCall($pDisp,"long","Server_CY",$DISPATCH_METHOD,"CY",GetCurrencyInt64(30,40),"CY*",0) $CY_OUT = $Return[2] $CurrencyStruct = GetCurrencyStruct($CY_OUT) $MsgText = "Server_CY" & @CRLF & @CRLF $MsgText &= "Lo = " & DllStructGetData($CurrencyStruct,1) & @CRLF $MsgText &= "Hi = " & DllStructGetData($CurrencyStruct,2) & @CRLF MsgBox(0,"CY_OUT",$MsgText) $DECIMAL = DllStructCreate($tagDEC) ;-------------- Set In ----------- DllStructSetData($DECIMAL,2,2) DllStructSetData($DECIMAL,3,3) DllStructSetData($DECIMAL,4,4) DllStructSetData($DECIMAL,5,5) DllStructSetData($DECIMAL,6,6) ;-------------- Set In ----------- $Return = DispCall($pDisp,"long","Server_DECIMAL",$DISPATCH_METHOD,"DECIMAL",DllStructGetPtr($DECIMAL)) $MsgText = "Server_DECIMAL" & @CRLF & @CRLF $MsgText &= "scale = " & DllStructGetData($DECIMAL,2) & @CRLF $MsgText &= "sign = " & DllStructGetData($DECIMAL,3) & @CRLF $MsgText &= "Hi32 = " & DllStructGetData($DECIMAL,4) & @CRLF $MsgText &= "Lo32 = " & DllStructGetData($DECIMAL,5) & @CRLF $MsgText &= "Mid32 = " & DllStructGetData($DECIMAL,6) & @CRLF MsgBox(0,"DECIMAL_OUT",$MsgText) Exit While True WEnd EndFunc Func StartRun() CoInitializeEx(0,0) if ($CmdLine[0]) Then $Command = $CmdLine[1] if ($Command == "ServerRun") Then ServerMain() Exit EndIf EndIf ProgramMain() Exit EndFunc Func ServerRun($TimeOut) if (IsServerReady()) Then Return True if (@Compiled) Then Run(FileGetShortName(@AutoItExe) & " ServerRun") Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath) & " ServerRun") EndIf $begin = TimerInit() While ($TimeOut > TimerDiff($begin)) $IsServerReady = IsServerReady() if ($IsServerReady) Then ExitLoop WEnd Return $IsServerReady EndFunc Func IsServerReady() $IFactory = CoGetClassObject($CServeClsid,$CLSCTX_LOCAL_SERVER,0,$IID_IClassFactory) ; Get ClassFactory if @error Then Return False InterfaceCall($IFactory,"long",3) ; Release Return True EndFunc Func DispatchCServerCreate() ServerRun(5000) $IFactory = CoGetClassObject($CServeClsid,$CLSCTX_LOCAL_SERVER,0,$IID_IClassFactory) ; Get ClassFactory if @error Then Return SetError(1,0,0) $Return = InterfaceCall($IFactory,"long",4,"ptr",0,"struct*",$IID_IDispatch,"ptr*",0) ; Call Factory_CreateInstance is Nu 4 if @error Or ($Return[0] <> 0) Then Return SetError(2,0,0) $pDisp = $Return[3] Return $pDisp EndFunc Server32.au3 #include "Class_Interface.au3" #include "TypeInfo.au3" #include <Array.au3> Global $TypeInfo = 0 Global $CServeClsid = CLSIDFromString("{B331A1D3-F796-4A60-B429-7A911142EA54}") Global $IID_IClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}") Global $IID_IDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}") Func ServerMain() $TypeInfo = MakeCServerTypeInfo() if @error Then Exit $FactoryPtr = NewIClassFactory() if @error Then Exit $dwRegister = CoRegisterClassObject($CServeClsid,$FactoryPtr,$CLSCTX_LOCAL_SERVER,$REGCLS_MULTIPLEUSE) if @error Then Exit While True WEnd EndFunc Func NewIClassFactory() Local $tagIClassFactory = "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;" & _ "ULONG_PTR CreateInstance;ULONG_PTR LockServer;UINT AddRefCount" $FactoryPtr = NewClass($tagIClassFactory) if @error Then Return SetError(1,0,0) SetClassMethod($FactoryPtr,"QueryInterface","Factory_QueryInterface","long","ptr;ptr;ptr") if @error Then Return SetError(2,0,0) SetClassMethod($FactoryPtr,"AddRef","Factory_AddRef","long","ptr") if @error Then Return SetError(3,0,0) SetClassMethod($FactoryPtr,"Release","Factory_Release","long","ptr") if @error Then Return SetError(4,0,0) SetClassMethod($FactoryPtr,"CreateInstance","Factory_CreateInstance","long","ptr;ptr;ptr;ptr") if @error Then Return SetError(5,0,0) SetClassMethod($FactoryPtr,"LockServer","Factory_LockServer","long","ptr;bool") if @error Then Return SetError(6,0,0) Factory_AddRef($FactoryPtr) Return $FactoryPtr EndFunc Func NewCServe() Local $tagServerClass = "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;" & _ "ULONG_PTR GetTypeInfoCount;ULONG_PTR GetTypeInfo;ULONG_PTR GetIDsOfNames;ULONG_PTR Invoke;" & _ "ULONG_PTR DataTypeA;ULONG_PTR DataTypeB;ULONG_PTR BSTR;ULONG_PTR VARIANT;ULONG_PTR ARRAY;" & _ "ULONG_PTR DATE;ULONG_PTR CY;ULONG_PTR DECIMAL;UINT AddRefCount" $ServerPtr = NewClass($tagServerClass) if @error Then Return SetError(1,0,0) SetClassMethod($ServerPtr,"QueryInterface","Server_QueryInterface","long","ptr;ptr;ptr") if @error Then Return SetError(2,0,0) SetClassMethod($ServerPtr,"AddRef","Server_AddRef","long","ptr") if @error Then Return SetError(3,0,0) SetClassMethod($ServerPtr,"Release","Server_Release","long","ptr") if @error Then Return SetError(4,0,0) SetClassMethod($ServerPtr,"GetTypeInfoCount","Server_GetTypeInfoCount","long","ptr;ptr") if @error Then Return SetError(5,0,0) SetClassMethod($ServerPtr,"GetTypeInfo","Server_GetTypeInfo","long","ptr;long;dword;ptr") if @error Then Return SetError(6,0,0) SetClassMethod($ServerPtr,"GetIDsOfNames","Server_GetIDsOfNames","long","ptr;ptr;ptr;long;dword;ptr") if @error Then Return SetError(7,0,0) SetClassMethod($ServerPtr,"Invoke","Server_Invoke","long","ptr;long;ptr;dword;word;ptr;ptr;ptr;ptr") if @error Then Return SetError(8,0,0) $MRegDataType = "PTR;BYTE;PTR;BOOLEAN;PTR;SHORT;PTR;USHORT;PTR;WORD;PTR;INT;PTR;LONG;PTR;BOOL;PTR;UINT;PTR;ULONG;PTR" SetClassMethod($ServerPtr,"DataTypeA","Server_DataTypeA","long",$MRegDataType) if @error Then Return SetError(9,0,0) $MRegDataType = "PTR;DWORD;PTR;INT64;PTR;UINT64;PTR;FLOAT;PTR;DOUBLE;PTR;LPARAM;PTR;WPARAM;PTR;SHORT;PTR" SetClassMethod($ServerPtr,"DataTypeB","Server_DataTypeB","long",$MRegDataType) if @error Then Return SetError(10,0,0) SetClassMethod($ServerPtr,"BSTR","Server_BSTR","long","PTR;PTR;PTR") if @error Then Return SetError(11,0,0) SetClassMethod($ServerPtr,"VARIANT","Server_VARIANT","long","PTR;PTR") if @error Then Return SetError(12,0,0) SetClassMethod($ServerPtr,"ARRAY","Server_ARRAY","long","PTR;PTR;PTR") if @error Then Return SetError(13,0,0) SetClassMethod($ServerPtr,"DATE","Server_DATE","long","PTR;double;PTR") if @error Then Return SetError(14,0,0) SetClassMethod($ServerPtr,"CY","Server_CY","long","PTR;INT64;PTR") if @error Then Return SetError(15,0,0) SetClassMethod($ServerPtr,"DECIMAL","Server_DECIMAL","long","PTR;PTR") if @error Then Return SetError(16,0,0) Server_AddRef($ServerPtr) Return $ServerPtr EndFunc Func MakeCServerTypeInfo() $InterfaceDataSt = MakeInterfaceData(15) MakeMethodData($InterfaceDataSt,1,"Server_QueryInterface",2,"long") MakeMethodData($InterfaceDataSt,2,"Server_AddRef",0,"long") MakeMethodData($InterfaceDataSt,3,"Server_Release",0,"long") MakeMethodData($InterfaceDataSt,4,"Server_GetTypeInfoCount",1,"long") MakeMethodData($InterfaceDataSt,5,"Server_GetTypeInfo",3,"long") MakeMethodData($InterfaceDataSt,6,"Server_GetIDsOfNames",5,"long") MakeMethodData($InterfaceDataSt,7,"Server_Invoke",8,"long") MakeMethodData($InterfaceDataSt,8,"Server_DataTypeA",20,"long") MakeMethodData($InterfaceDataSt,9,"Server_DataTypeB",16,"long") MakeMethodData($InterfaceDataSt,10,"Server_BSTR",2,"long") MakeMethodData($InterfaceDataSt,11,"Server_VARIANT",1,"long") MakeMethodData($InterfaceDataSt,12,"Server_ARRAY",2,"long") MakeMethodData($InterfaceDataSt,13,"Server_DATE",2,"long") MakeMethodData($InterfaceDataSt,14,"Server_CY",2,"long") MakeMethodData($InterfaceDataSt,15,"Server_DECIMAL",1,"long") MakeParamData($InterfaceDataSt,1,"ptr","riid","ptr","ppvObject") MakeParamData($InterfaceDataSt,4,"ptr","pctinfo") MakeParamData($InterfaceDataSt,5,"long","itinfo","DWORD","lcid","ptr","pptinfo") MakeParamData($InterfaceDataSt,6,"ptr","riid","ptr","rgszNames","long","cNames","DWORD","lcid","ptr","rgdispid") MakeParamData($InterfaceDataSt,7,"ptr","dispidMember","ptr","riid","DWORD","lcid","WORD","wFlags", _ "ptr","pdispParams","ptr","pvarResult","ptr","pExcepInfo","ptr","puArgErr") MakeParamData($InterfaceDataSt,8,"BYTE","BYTE_IN","BYTE*","BYTE_OUT","BOOLEAN","BOOLEAN_IN","BOOLEAN*","BOOLEAN_OUT" _ ,"SHORT","SHORT_IN","SHORT*","SHORT_OUT","USHORT","USHORT_IN","USHORT*","USHORT_OUT","WORD","WORD_IN","WORD*","WORD_OUT" _ ,"INT","INT_IN","INT*","INT_OUT","LONG","LONG_IN","LONG*","LONG_OUT","BOOL","BOOL_IN","BOOL*","BOOL_OUT","UINT","UINT_IN", _ "UINT*","UINT_OUT","ULONG","ULONG_IN","ULONG*","ULONG_OUT") MakeParamData($InterfaceDataSt,9,"DWORD","DWORD_IN","DWORD*","DWORD_OUT","INT64","INT64_IN","INT64*","INT64_OUT","UINT64", _ "UINT64_IN","UINT64*","UINT64_OUT","FLOAT","FLOAT_IN","FLOAT*","FLOAT_OUT","DOUBLE","DOUBLE_IN","DOUBLE*","DOUBLE_OUT", _ "LPARAM","LPARAM_IN","LPARAM*","LPARAM_OUT","WPARAM","WPARAM_IN","WPARAM*","WPARAM_OUT","VBOOL","VBOOL_IN","VBOOL*","VBOOL_OUT") MakeParamData($InterfaceDataSt,10,"BSTR","BSTR_IN","BSTR*","BSTR_OUT") MakeParamData($InterfaceDataSt,11,"VARIANT","VARIANT_IN_OUT") MakeParamData($InterfaceDataSt,12,"ARRAY","ARRAY_IN","ARRAY*","ARRAY_OUT") MakeParamData($InterfaceDataSt,13,"DATE","DATE_IN","DATE*","DATE_OUT") MakeParamData($InterfaceDataSt,14,"CY","CY_IN","CY*","CY_OUT") MakeParamData($InterfaceDataSt,15,"DECIMAL","DECIMAL_IN_OUT") $TypeInfo = CreateDispTypeInfo($InterfaceDataSt) if @error Then Return SetError(1,0,0) Return $TypeInfo EndFunc Func Factory_QueryInterface($Interface,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if IsEqualIID($riid,"{00000000-0000-0000-C000-000000000046}") _ ; IUnknown Or IsEqualIID($riid,"{00000001-0000-0000-C000-000000000046}") Then ; IClassFactory SetOut("ULONG_PTR",$ppvObject,$Interface) Else Return 0x80004002 ; E_NOINTERFACE EndIf Factory_AddRef($Interface) Return 0 ; NOERROR EndFunc Func Factory_AddRef($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") + 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) Return $AddRefCount EndFunc Func Factory_Release($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") - 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) if ($AddRefCount = 0) Then DeleteClass($Interface) Return $AddRefCount EndFunc Func Factory_CreateInstance($Interface,$pUnkOuter,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if ($pUnkOuter) Then Return 0x80040110 ;CLASS_E_NOAGGREGATION $ServerPtr = NewCServe() if Not($ServerPtr) Then Return 0x80000002 ;E_OUTOFMEMORY $hr = InterfaceCall($ServerPtr,"long",1,"ptr",$riid,"ptr",$ppvObject) ; QueryInterface $hr = $hr[0] Server_Release($ServerPtr) Return $hr EndFunc Func Factory_LockServer($Interface,$fLock) Return 0 ; NOERROR EndFunc Func Server_QueryInterface($Interface,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if IsEqualIID($riid,"{00000000-0000-0000-C000-000000000046}") _ ; IUnknown Or IsEqualIID($riid,"{00020400-0000-0000-C000-000000000046}") Then ; IDispatch SetOut("ULONG_PTR",$ppvObject,$Interface) Else Return 0x80004002 ; E_NOINTERFACE EndIf Server_AddRef($Interface) Return 0 ; NOERROR EndFunc Func Server_AddRef($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") + 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) Return $AddRefCount EndFunc Func Server_Release($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") - 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) if ($AddRefCount = 0) Then DeleteClass($Interface) Return $AddRefCount EndFunc Func Server_GetTypeInfoCount($Interface,$pctinfo) if ($pctinfo = 0) Then Return 0x80000001 ;E_NOTIMPL SetOut("UINT",$pctinfo,1) Return 0 ; NOERROR EndFunc Func Server_GetTypeInfo($Interface,$itinfo,$lcid,$pptinfo) if ($pptinfo = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ptr",$pptinfo,0) if ($itinfo <> 0) Then Return 0x8002000B ; DISP_E_BADINDEX InterfaceCall($TypeInfo,"long",2) ; AddRef SetOut("ptr",$pptinfo,$TypeInfo) Return 0 ; NOERROR EndFunc Func Server_GetIDsOfNames($Interface,$riid,$rgszNames,$cNames,$lcid,$rgdispid) $hr = DllCall($OleAut32,"long","DispGetIDsOfNames","ptr",$TypeInfo,"ptr",$rgszNames,"long",$cNames,"ptr",$rgdispid) $hr = $hr[0] Return $hr EndFunc Func Server_Invoke($Interface,$dispidMember,$riid,$lcid,$wFlags,$pdispParams,$pvarResult,$pExcepInfo,$puArgErr) $hr = DllCall($OleAut32,"long","DispInvoke","ptr",$Interface,"ptr",$TypeInfo,"int",$dispidMember,"WORD",$wFlags _ ,"ptr",$pdispParams,"ptr",$pvarResult,"ptr",$pExcepInfo,"ptr",$puArgErr) $hr = $hr[0] Return $hr EndFunc Func Server_DataTypeA($Interface,$BYTE_IN,$BYTE_OUT,$BOOLEAN_IN,$BOOLEAN_OUT,$SHORT_IN,$SHORT_OUT,$USHORT_IN,$USHORT_OUT _ ,$WORD_IN,$WORD_OUT,$INT_IN,$INT_OUT,$LONG_IN,$LONG_OUT,$BOOL_IN,$BOOL_OUT,$UINT_IN,$UINT_OUT,$ULONG_IN,$ULONG_OUT) SetOut("BYTE",$BYTE_OUT,1) SetOut("BOOLEAN",$BOOLEAN_OUT,True) SetOut("SHORT",$SHORT_OUT,2) SetOut("USHORT",$USHORT_OUT,4) SetOut("WORD",$WORD_OUT,5) SetOut("INT",$INT_OUT,6) SetOut("LONG",$LONG_OUT,7) SetOut("BOOL",$BOOL_OUT,False) SetOut("UINT",$UINT_OUT,8) SetOut("ULONG",$ULONG_OUT,9) $MsgText = "Server_DataTypeA" & @CRLF & @CRLF $MsgText &= "BYTE_IN ==> " $MsgText &= $BYTE_IN & @CRLF $MsgText &= "BOOLEAN_IN ==> " $MsgText &= $BOOLEAN_IN & @CRLF $MsgText &= "SHORT_IN ==> " $MsgText &= $SHORT_IN & @CRLF $MsgText &= "USHORT_IN ==> " $MsgText &= $USHORT_IN & @CRLF $MsgText &= "WORD_IN ==> " $MsgText &= $WORD_IN & @CRLF $MsgText &= "INT_IN ==> " $MsgText &= $INT_IN & @CRLF $MsgText &= "LONG_IN ==> " $MsgText &= $LONG_IN & @CRLF $MsgText &= "BOOL_IN ==> " $MsgText &= $BOOL_IN & @CRLF $MsgText &= "UINT_IN ==> " $MsgText &= $UINT_IN & @CRLF $MsgText &= "ULONG_IN ==> " $MsgText &= $ULONG_IN & @CRLF MsgBox(0,"Server_DataTypeA",$MsgText) Return 100 EndFunc Func Server_DataTypeB($Interface,$DWORD_IN,$DWORD_OUT,$INT64_IN,$INT64_OUT,$UINT64_IN,$UINT64_OUT,$FLOAT_IN,$FLOAT_OUT,$DOUBLE_IN _ ,$DOUBLE_OUT,$LPARAM_IN,$LPARAM_OUT,$WPARAM_IN,$WPARAM_OUT,$VBOOL_IN,$VBOOL_OUT) SetOut("DWORD",$DWORD_OUT,10) SetOut("INT64",$INT64_OUT,11) SetOut("UINT64",$UINT64_OUT,12) SetOut("FLOAT",$FLOAT_OUT,13.5) SetOut("DOUBLE",$DOUBLE_OUT,14.6) SetOut("LPARAM",$LPARAM_OUT,_WinAPI_MakeLong(50, 60)) SetOut("WPARAM",$WPARAM_OUT,_WinAPI_MakeLong(70, 80)) SetOut("SHORT",$VBOOL_OUT,17) $MsgText = "Server_DataTypeB" & @CRLF & @CRLF $MsgText &= "DWORD_IN ==> " $MsgText &= $DWORD_IN & @CRLF $MsgText &= "INT64_IN ==> " $MsgText &= $INT64_IN & @CRLF $MsgText &= "UINT64_IN ==> " $MsgText &= $UINT64_IN & @CRLF $MsgText &= "FLOAT_IN ==> " $MsgText &= $FLOAT_IN & @CRLF $MsgText &= "DOUBLE_IN ==> " $MsgText &= $DOUBLE_IN & @CRLF $MsgText &= "LPARAM_IN ==> " $MsgText &= $LPARAM_IN & @CRLF $MsgText &= "LPARAM_HiWord ==> " $MsgText &= _WinAPI_HiWord($LPARAM_IN) & @CRLF $MsgText &= "LPARAM_LoWord ==> " $MsgText &= _WinAPI_LoWord($LPARAM_IN) & @CRLF $MsgText &= "WPARAM_IN ==> " $MsgText &= $WPARAM_IN & @CRLF $MsgText &= "WPARAM_HiWord ==> " $MsgText &= _WinAPI_HiWord($WPARAM_IN) & @CRLF $MsgText &= "WPARAM_LoWord ==> " $MsgText &= _WinAPI_LoWord($WPARAM_IN) & @CRLF $MsgText &= "SHORT_IN Or VBOOL_IN ==> " $MsgText &= $VBOOL_IN & @CRLF MsgBox(0,"Server_DataTypeB",$MsgText) Return 200 EndFunc Func Server_BSTR($Interface,$BSTR_IN,$BSTR_OUT) SetOut("PTR",$BSTR_OUT,StrToBstr("BSTR_OUT")) MsgBox(0,"BSTR_IN",BstrToStr($BSTR_IN)) Return 400 EndFunc Func Server_VARIANT($Interface,$VARIANT_IN_OUT) $Variant = DllStructCreate($tagVariant,$VARIANT_IN_OUT) $Long = GetUnionOfVariant($Variant,"long") MsgBox(0,"VARIANT_IN",$Long) DllStructSetData($Variant,"vt",GetDataTypeNu("BSTR")) SetUnionOfVariant($Variant,"ptr",StrToBstr("VARIANT_OUT")) Return 500 EndFunc Func Server_ARRAY($Interface,$ARRAY_IN,$ARRAY_OUT) SetOut("PTR",$ARRAY_OUT,SafeArrayCreate("byte",1,1000)) MsgBox(0,"ARRAY_IN",$ARRAY_IN) Return 700 EndFunc Func Server_DATE($Interface,$DATE_IN,$DATE_OUT) $DoubleTime = GetDoubleTime(2014,1,7,10,3,20,10,0) SetOut("double",$DATE_OUT,$DoubleTime) $TimeArray = GetSystemTime($DATE_IN) $MsgText = "Server_DATE" & @CRLF & @CRLF $MsgText &= $TimeArray[0][1] & " = " & $TimeArray[0][0] & @CRLF $MsgText &= $TimeArray[1][1] & " = " & $TimeArray[1][0] & @CRLF $MsgText &= $TimeArray[2][1] & " = " & $TimeArray[2][0] & @CRLF $MsgText &= $TimeArray[3][1] & " = " & $TimeArray[3][0] & @CRLF $MsgText &= $TimeArray[4][1] & " = " & $TimeArray[4][0] & @CRLF $MsgText &= $TimeArray[5][1] & " = " & $TimeArray[5][0] & @CRLF $MsgText &= $TimeArray[6][1] & " = " & $TimeArray[6][0] & @CRLF $MsgText &= $TimeArray[7][1] & " = " & $TimeArray[7][0] MsgBox(0,"DATE_IN",$MsgText) Return 800 EndFunc Func Server_CY($Interface,$CY_IN,$CY_OUT) SetOut("Int64",$CY_OUT,GetCurrencyInt64(10,20)) $CurrencyStruct = GetCurrencyStruct($CY_IN) $MsgText = "Server_CY" & @CRLF & @CRLF $MsgText &= "Lo = " & DllStructGetData($CurrencyStruct,1) & @CRLF $MsgText &= "Hi = " & DllStructGetData($CurrencyStruct,2) & @CRLF MsgBox(0,"CY_IN",$MsgText) Return 900 EndFunc Func Server_DECIMAL($Interface,$DECIMAL_IN_OUT) $DECIMAL = DllStructCreate($tagDEC,$DECIMAL_IN_OUT) $MsgText = "Server_DECIMAL" & @CRLF & @CRLF $MsgText &= "scale = " & DllStructGetData($DECIMAL,2) & @CRLF $MsgText &= "sign = " & DllStructGetData($DECIMAL,3) & @CRLF $MsgText &= "Hi32 = " & DllStructGetData($DECIMAL,4) & @CRLF $MsgText &= "Lo32 = " & DllStructGetData($DECIMAL,5) & @CRLF $MsgText &= "Mid32 = " & DllStructGetData($DECIMAL,6) & @CRLF MsgBox(0,"DECIMAL_IN",$MsgText) ;-------------- Set Out ----------- DllStructSetData($DECIMAL,2,7) DllStructSetData($DECIMAL,3,8) DllStructSetData($DECIMAL,4,9) DllStructSetData($DECIMAL,5,10) DllStructSetData($DECIMAL,6,11) ;-------------- Set Out ----------- Return 1000 EndFunc Class_Interface.au3 #include "Constants.au3" #include "DataType.au3" Func NewClass($tagClass) $ClassStA = DllStructCreate($tagClass) if @error Then Return SetError(1,0,0) $ClassStB = DllStructCreate("ULONG_PTR") if @error Then Return SetError(2,0,0) DllStructSetData($ClassStB,1,DllStructGetPtr($ClassStA)) $ClassStBPtr = DllStructGetPtr($ClassStB) $UBound = (UBound($StOfClassArray) - 1) $StOfClassArray[$UBound][0] = $ClassStA $StOfClassArray[$UBound][1] = $ClassStB $StOfClassArray[$UBound][2] = $ClassStBPtr ReDim $StOfClassArray[$UBound + 2][4] Return $ClassStBPtr EndFunc Func SetClassMethod($ClassStBPtr,$MethodName,$FuncName,$ReturnDataType,$ParamsDataType) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,False) $ClassStA = $StOfClassArray[$Element][0] DllStructGetData($ClassStA,$MethodName) if @error Then Return SetError(2,0,False) $RegCallbackFunc = DllCallbackRegister($FuncName,$ReturnDataType,$ParamsDataType) if Not($RegCallbackFunc) Then Return SetError(3,0,False) $CallbackFuncPtr = DllCallbackGetPtr($RegCallbackFunc) $RegFuncArray = $StOfClassArray[$Element][3] if Not IsArray($RegFuncArray) Then Dim $RegFuncArray[1] Else ReDim $RegFuncArray[(UBound($RegFuncArray) + 1)] EndIf $RegFuncArray[(UBound($RegFuncArray) - 1)] = $RegCallbackFunc $StOfClassArray[$Element][3] = $RegFuncArray DllStructSetData($ClassStA,$MethodName,$CallbackFuncPtr) Return True EndFunc Func ClassSetData($ClassStBPtr,$ElementName,$Value) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,False) $ClassStA = $StOfClassArray[$Element][0] DllStructSetData($ClassStA,$ElementName,$Value) if @error Then Return SetError(2,0,False) Return True EndFunc Func ClassGetData($ClassStBPtr,$ElementName) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,0) $ClassStA = $StOfClassArray[$Element][0] $Value = DllStructGetData($ClassStA,$ElementName) if @error Then Return SetError(2,0,0) Return $Value EndFunc Func ClassGetElementPtr($ClassStBPtr,$ElementName) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,0) $ClassStA = $StOfClassArray[$Element][0] $ElementPtr = DllStructGetPtr($ClassStA,$ElementName) if @error Then Return SetError(2,0,0) Return $ElementPtr EndFunc Func FindClassSt($ClassStBPtr) For $Element = 0 To (UBound($StOfClassArray) - 2) if ($ClassStBPtr = $StOfClassArray[$Element][2]) Then Return $Element Next Return SetError(1,0,-1) EndFunc Func DeleteClass($ClassStBPtr) Local $UBound = UBound($StOfClassArray) Dim $NewStOfClassArray[$UBound][4] Local $iElement = 0 , $TestDelete = False For $Element = 0 To ($UBound - 2) if ($ClassStBPtr = $StOfClassArray[$Element][2]) Then $RegFuncArray = $StOfClassArray[$Element][3] For $nElement = 0 To UBound($RegFuncArray) - 1 $RegCallbackFunc = $RegFuncArray[$nElement] DllCallbackFree($RegCallbackFunc) Next $TestDelete = True Else $NewStOfClassArray[$iElement][0] = $StOfClassArray[$Element][0] $NewStOfClassArray[$iElement][1] = $StOfClassArray[$Element][1] $NewStOfClassArray[$iElement][2] = $StOfClassArray[$Element][2] $NewStOfClassArray[$iElement][3] = $StOfClassArray[$Element][3] $iElement += 1 EndIf Next if ($TestDelete) Then if ($UBound > 1) Then ReDim $NewStOfClassArray[$UBound - 1][4] $StOfClassArray = $NewStOfClassArray Return True Else Return SetError(1,0,False) EndIf EndFunc Func SetOut($DataType,$OutPtr,$SetValue) Return DllStructSetData(DllStructCreate($DataType,$OutPtr),1,$SetValue) EndFunc Func GetOut($DataType,$OutPtr) Return DllStructGetData(DllStructCreate($DataType,$OutPtr),1) EndFunc Func IsEqualIID($IID_A,$IID_B) if Not IsString($IID_A) Then $IID_A = _WinAPI_StringFromGUID($IID_A) if $IID_A == "" Then Return SetError(1,0,False) Else if Not IsDllStruct(_WinAPI_GUIDFromString($IID_A)) Then Return SetError(1,0,False) EndIf if Not IsString($IID_B) Then $IID_B = _WinAPI_StringFromGUID($IID_B) if $IID_B == "" Then Return SetError(2,0,False) Else if Not IsDllStruct(_WinAPI_GUIDFromString($IID_B)) Then Return SetError(2,0,False) EndIf if ($IID_A == $IID_B) Then Return True Else Return False EndIf EndFunc Func DispCall($pDisp,$RtType,$MemberName,$MemberType,$Type1 = "",$Param1 = 0,$Type2 = "",$Param2 = 0 _ ,$Type3 = "",$Param3 = 0, $Type4 = "", $Param4 = 0,$Type5 = 0 ,$Param5 = 0, $Type6 = "", $Param6 = 0 _ ,$Type7 = "",$Param7 = 0,$Type8 = "", $Param8 = 0,$Type9 = "",$Param9 = 0,$Type10 = "", $Param10 = 0 _ ,$Type11= "",$Param11= 0,$Type12= "", $Param12= 0,$Type13= "",$Param13 = 0,$Type14 = "",$Param14 = 0 _ ,$Type15= "",$Param15= 0,$Type16= "", $Param16= 0,$Type17= "",$Param17 = 0,$Type18 = "",$Param18 = 0 _ ,$Type19= "",$Param19= 0,$Type20= "", $Param20= 0,$Type21= "",$Param21 = 0,$Type22 = "",$Param22 = 0 _ ,$Type23= "",$Param23= 0,$Type24= "", $Param24= 0,$Type25= "",$Param25 = 0,$Type26 = "",$Param26 = 0 _ ,$Type27= "",$Param27= 0,$Type28= "", $Param28= 0,$Type29= "",$Param29 = 0,$Type30 = "",$Param30 = 0) if ((@NumParams > 4) And (Mod((@NumParams - 4),2) <> 0)) Then Return SetError(1,0,0) Local $NumParams = ((@NumParams - 4) / 2) $ptNameSt = DllStructCreate("WCHAR[" & (StringLen($MemberName) + 1) & "]") DllStructSetData($ptNameSt,1,$MemberName) $StArrayName = DllStructCreate("ptr") DllStructSetData($StArrayName,1,DllStructGetPtr($ptNameSt)) $HRESULT = InterfaceCall($pDisp,"long",6,"struct*",$IID_NULL,"struct*",$StArrayName,"UINT",1,"DWORD",0,"long*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(2,0,0) ; Call Server_GetIDsOfNames Is Nu 6 Local $dispID = $HRESULT[5] $rgvarg = DllStructCreate("byte[" & ($VariantSize * $NumParams) & "]") $rgvargPtr = DllStructGetPtr($rgvarg) Local $nReturn[$NumParams + 1][2] , $Variant = 0 , $RtVariant = 0 , $DISPID_PROPERTYPUT = -3 For $i = 0 To $NumParams if ($i = 0) Then $RtVariant = DllStructCreate($tagVariant) $Variant = $RtVariant $Value = "" $DataType = $RtType $DataTypeNu = GetDataTypeNu($DataType) if @error Then Return SetError(3,0,0) Else $Variant = DllStructCreate($tagVariant,$rgvargPtr + (($NumParams - $i) * $VariantSize)) $Value = Eval("Param" & $i) $DataType = Eval("Type" & $i) $DataTypeNu = GetDataTypeNu($DataType) if @error Then Return SetError(3,0,0) EndIf $BOOLREF = @extended $DataType = StringReplace($DataType,"*","") $nReturn[$i][0] = $BOOLREF Switch $DataType Case "BSTR","DISPATCH","UNKNOWN","ARRAY" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",$Value) EndSwitch Case "VARIANT","DECIMAL" if Not IsPtr($Value) Or $Value = Ptr(0) Then Return SetError(4,0,0) $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",$Value) Case "CY" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("INT64") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"INT64",$Value) EndSwitch Case "DATE" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("double") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"double",$Value) EndSwitch Case "ERROR" ;Scode Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("long") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"long",$Value) EndSwitch Case "VBOOL" ;VARIANT_BOOL short A 16-bit ;typedef short VARIANT_BOOL; Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("short") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"short",$Value) EndSwitch Case Else Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef($DataType) SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,$DataType,$Value) EndSwitch EndSwitch DllStructSetData($Variant,"vt",$DataTypeNu) Next $DISPPARAMS = DllStructCreate($tagDISPPARAMS) DllStructSetData($DISPPARAMS,"cArgs",$NumParams) DllStructSetData($DISPPARAMS,"rgvarg",$rgvargPtr) if BitAND($MemberType,$DISPATCH_PROPERTYPUT) Then $rgdispidNamedArgsSt = DllStructCreate("long") DllStructSetData($rgdispidNamedArgsSt,1,$DISPID_PROPERTYPUT) DllStructSetData($DISPPARAMS,"rgdispidNamedArgs",DllStructGetPtr($rgdispidNamedArgsSt)) DllStructSetData($DISPPARAMS,"cNamedArgs",1) EndIf $HRESULT = InterfaceCall($pDisp,"long",7,"long",$dispID,"struct*",$IID_NULL,"DWORD",0, _ "WORD",$MemberType,"struct*",$DISPPARAMS,"struct*",$RtVariant,"ptr*",0,"UINT*",0) ; Call Server_Invoke Is Nu 7 if @error Or $HRESULT[0] <> 0 Then Return SetError(5,0,0) Local $vReturn[($NumParams + 1)] For $i = 0 To $NumParams $BOOLREF = $nReturn[$i][0] $Value = $nReturn[$i][1] if ($i = 0) Then if ($BOOLREF) Then if IsDllStruct($Value) Then $Value = GetByRefValue($Value) $vReturn[$i] = $Value Else $vReturn[$i] = GetUnionOfVariant($RtVariant,$RtType) EndIf Else if ($BOOLREF) Then if IsDllStruct($Value) Then $Value = GetByRefValue($Value) $vReturn[$i] = $Value Else $vReturn[$i] = $Value EndIf EndIf Next Return $vReturn EndFunc Func InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0,$Type2 = 0,$Param2 = 0 _ ,$Type3 = 0,$Param3 = 0, $Type4 = 0,$Param4 = 0 ,$Type5 = 0 ,$Param5 = 0,$Type6 = 0,$Param6 = 0 _ ,$Type7 = 0,$Param7 = 0, $Type8 = 0,$Param8 = 0,$Type9 = 0,$Param9 = 0,$Type10 = 0,$Param10 = 0 _ ,$Type11= 0,$Param11= 0,$Type12= 0,$Param12= 0,$Type13= 0,$Param13 = 0,$Type14 = 0,$Param14 = 0 _ ,$Type15= 0,$Param15= 0,$Type16= 0,$Param16= 0,$Type17= 0,$Param17 = 0,$Type18 = 0,$Param18 = 0 _ ,$Type19= 0,$Param19= 0,$Type20= 0,$Param20= 0,$Type21= 0,$Param21 = 0,$Type22 = 0,$Param22 = 0 _ ,$Type23= 0,$Param23= 0,$Type24= 0,$Param24= 0,$Type25= 0,$Param25 = 0,$Type26 = 0,$Param26 = 0 _ ,$Type27= 0,$Param27= 0,$Type28= 0,$Param28= 0,$Type29= 0,$Param29 = 0,$Type30 = 0,$Param30 = 0) ;;Return Array Of DllCallAddress ;Only Call Virtual Method Form any Class Or From any Interface ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) ;See the examples ;-------------------------------------------------------------------;C++ Example1 ;C++ Example1 ;class iClass ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;void MethodB() ;{ ;MessageBox(0,"MethodB","MSG",0); ;} ;virtual void VirtualMethodA() ;{ ;MessageBox(0,"VirtualMethodA","MSG",0); ;} ;}; ;-----------------------------------------------------------;Virtual Methods Table ;Virtual Methods Table ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;virtual void VirtualMethodA() ==> Virtual Method Number Is 3 ;-----------------------------------------------------------;Virtual Methods Table ;-------------------------------------------------------------------;C++ Example1 ;//////////////////////////////////////////////////////////////////////////////// ;-------------------------------------------------------------------;C++ Example2 ;C++ Example2 ;class iClassA ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;}; ;class iClassB : public iClassA ;{ ;public: ;void MethodD() ;{ ;MessageBox(0,"MethodD","MSG",0); ;} ;virtual void VirtualMethodF() ;{ ;MessageBox(0,"VirtualMethodF","MSG",0); ;} ;virtual void VirtualMethodE() ;{ ;MessageBox(0,"VirtualMethodE","MSG",0); ;} ;}; ;//////////////////////////////////////////////////////////////////////////////// ;//////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassA Class ;Virtual Methods Table Of iClassA Class ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;------------------------------------------;Virtual Methods Table Of iClassA Class ;//////////////////////////////////////////////////////////////////////////////// ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassB Class ;class iClassB : public iClassA ;base class ==> iClassA ;derived class ==> iClassB ;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx ;When preceding the name of a base class, the public keyword specifies that the public ;and protected members of the base class are public and protected members, respectively, ;of the derived class. ;------------------------------------------------------------------------------------- ;Virtual Methods Table Of iClassB Class ;virtual void VirtualMethodB() In (iClassA) ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() In (iClassA) ==> Virtual Method Number Is 2 ;virtual void VirtualMethodF() In (iClassB) ==> Virtual Method Number Is 3 ;virtual void VirtualMethodE() In (iClassB) ==> Virtual Method Number Is 4 ;------------------------------------------;Virtual Methods Table Of iClassB Class ;-------------------------------------------------------------------;C++ Example2 ;//////////////////////////////////////////////////////////////////////////////// if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) if (@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0) Then Return SetError(2,0,0) Local $iMethAddress = GetMethodAddress($Inface,$MethodNum) if Not ($iMethAddress) Then Return SetError(3,0,0) Local $iDataType = "",$iFuncParam = "",$iCommand = "",$iReturn = 0 ;Why use Inface Param In DllCallAddress Function Because the Function of the method ;starts from the (Interface Or class) ;See here ;int class::MethodFunction( int Param ){return 0;}; $iCommand = 'DllCallAddress("' & $ReturnType & '",Eval("iMethAddress"),"ptr",Eval("Inface"),' For $i = 1 To ((@NumParams - 3) / 2) $iDataType = Eval("Type" & $i) $iCommand &= '"' & $iDataType & '",' $iFuncParam = 'Eval("Param' & $i & '"),' $iCommand &= $iFuncParam Next $iCommand = StringTrimRight($iCommand,1) $iCommand &= ")" $iReturn = Execute($iCommand) if @error Then Return SetError(4,0,0) Local $nReturn[UBound($iReturn) -1] , $j = 0 For $i = 0 To UBound($iReturn) - 1 if ($i = 1) Then ContinueLoop ;Skip $Inface Element $nReturn[$j] = $iReturn[$i] $j += 1 Next Return SetError(0,0,$nReturn) EndFunc Func GetMethodAddress($Inface,$MethodNum) ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) Local $iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then Return SetError(2,0,0) Return SetError(0,0,$iMethAddress) EndFunc Func GetCount_Of_VirtualMethods($Inface) Local $iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 , $MethodNum = 1 if Not IsPtr($Inface) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- While 1 ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",DllStructGetData($OutCastStruct1,1) + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then $MethodNum -= 1 ExitLoop Else $MethodNum += 1 EndIf WEnd Return SetError(0,0,$MethodNum) EndFunc Func IsBadCodePtr($lpfn) Local $iReturn $iReturn = DllCall("Kernel32.dll","BOOL","IsBadCodePtr","ptr",$lpfn) if @error Then Return SetError(1,0,0) Return SetError(0,0,$iReturn[0]) EndFunc Func GetObjFromGuid($dwClsContext,$StrIID,$StrCLSID) $clsid = CLSIDFromString($StrCLSID) if @error Then Return SetError(2,0,0) $riid = IIDFromString($StrIID) if @error Then Return SetError(3,0,0) $Rt = DllCall($Ole32,"long","CoCreateInstance","ptr",DllStructGetPtr($clsid), _ "ptr",0,"DWORD",$dwClsContext,"ptr",DllStructGetPtr($riid),"ptr*",0) if @error Or $Rt[0] <> 0 Then Return SetError(4,0,$Rt[0]) Return SetError(0,0,$Rt[5]) EndFunc Func CoGetClassObject($rclsid,$dwClsContext,$pServerInfo,$riid) $HRESULT = DllCall($Ole32,"long","CoGetClassObject","struct*",$rclsid, _ "DWORD",$dwClsContext,"ptr",$pServerInfo,"struct*",$riid,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,$HRESULT[0]) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRegisterClassObject($rclsid,$pUnk,$dwClsContext,$flags) $HRESULT = DllCall($Ole32,"long","CoRegisterClassObject","struct*",$rclsid _ ,"ptr",$pUnk,"DWORD",$dwClsContext,"DWORD",$flags,"DWORD*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,$HRESULT[0]) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRegisterPSClsid($riid,$rclsid) $HRESULT = DllCall($Ole32,"long","CoRegisterPSClsid","struct*",$riid,"struct*",$rclsid) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[0]) EndFunc Func CoGetPSClsid($riid) $HRESULT = DllCall($Ole32,"long","CoGetPSClsid","struct*",$riid,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[2]) EndFunc Func CoCreateGuid($ClipPut = False) Local $nGUID = DllStructCreate($tagnGUID) $HRESULT = DllCall($Ole32,"long","CoCreateGuid","struct*",$nGUID) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) if ($ClipPut) Then ClipPut(_WinAPI_StringFromGUID($nGUID)) Return SetError(0,0,_WinAPI_StringFromGUID($nGUID)) EndFunc Func RegisterActiveObject($punk,$rclsid,$dwFlags) $HRESULT = DllCall($Ole32,"long","RegisterActiveObject","ptr",$punk _ ,"struct*",$rclsid,"DWORD",$dwFlags,"DWORD*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRevokeClassObject($dwRegister) $HRESULT = DllCall($Ole32,"long","CoRevokeClassObject","DWORD",$dwRegister) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,False) Return SetError(0,0,True) EndFunc Func CoInitializeEx($pvReserved,$dwCoInit) $HRESULT = DllCall($Ole32,"int","CoInitializeEx","ptr",$pvReserved,"DWORD",$dwCoInit) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,False) Return SetError(0,0,True) EndFunc Func CLSIDFromString($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","CLSIDFromString","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func IIDFromString($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","IIDFromString","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func CLSIDFromProgID($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","CLSIDFromProgID","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func MIDL_DEFINE_GUID($Elm1,$Elm2,$Elm3,$iElm1,$iElm2,$iElm3,$iElm4,$iElm5,$iElm6,$iElm7,$iElm8) $vGUID = DllStructCreate($tagnGUID) DllStructSetData($vGUID,1,$Elm1) DllStructSetData($vGUID,2,$Elm2) DllStructSetData($vGUID,3,$Elm3) DllStructSetData($vGUID,4,$iElm1,1) DllStructSetData($vGUID,4,$iElm2,2) DllStructSetData($vGUID,4,$iElm3,3) DllStructSetData($vGUID,4,$iElm4,4) DllStructSetData($vGUID,4,$iElm5,5) DllStructSetData($vGUID,4,$iElm6,6) DllStructSetData($vGUID,4,$iElm7,7) DllStructSetData($vGUID,4,$iElm8,8) Return $vGUID EndFunc DataType.au3 #include-once #include "Constants.au3" Func GetDataTypeNu($DataType,$SafeArray_vt = False) ;$SafeArray_vt See SafeArrayCreate Func ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms683835%28v=vs.85%29.aspx ;There are two main types of servers, in-process and out-of-process. In-process servers are implemented in a ;dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process ;servers can reside either on the local computer or on a remote computer. In addition, COM provides a mechanism that ;allows an in-process server (a DLL) to run in a surrogate EXE process to gain the advantage of being able to run the ;process on a remote computer. For more information, see DLL Surrogates. ;(in Exe Server) Ptr Of Proc Or Ptr Of Out Struct Not Allowed Only ;Ptr Of Data Type like (int* DllStructGetPtr(DllStructCreate("int")) ,SHORT* DllStructGetPtr(DllStructCreate("SHORT")) ) or ;((ARRAY A SAFEARRAY pointer),(DISPATCH pointer),(UNKNOWN pointer),(BSTR pointer)) Or ;Ptr Of VARIANT Struct Or Ptr Of DECIMAL Struct ; See code in thes Func ;VARIANT structure ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx ;VARENUM enumeration ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221170%28v=vs.85%29.aspx Local $DataTypeNu , $VT_BYREF = 0x4000 Local $BOOLREF = (StringInStr($DataType,"*") <> 0) $DataType = StringReplace(StringUpper($DataType),"*","") Switch $DataType Case "NONE" $DataTypeNu = 24 Case "BYTE","BOOLEAN" ;Autoit BOOLEAN like BYTE 17 $DataTypeNu = 17 Case "SHORT" $DataTypeNu = 2 Case "USHORT","WORD" $DataTypeNu = 18 Case "INT","LONG","BOOL" ; Autoit BOOL like LONG 22 $DataTypeNu = 22 Case "UINT","ULONG","DWORD" $DataTypeNu = 23 Case "INT64" $DataTypeNu = 20 Case "UINT64" $DataTypeNu = 21 Case "FLOAT" $DataTypeNu = 4 Case "DOUBLE" $DataTypeNu = 5 ;--------------------------------------------------------------------------------------------- ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt. Case "HWND" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "HANDLE" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "LPARAM","INT_PTR","LONG_PTR","LRESULT" ;32 or 64bit signed integer if (@AutoItX64) Then $DataTypeNu = 20 ;VT_I8 Else $DataTypeNu = 3 ;VT_I4 EndIf Case "PTR","UINT_PTR","ULONG_PTR","DWORD_PTR","WPARAM";32 or 64bit unsigned integer if (@AutoItX64) Then $DataTypeNu = 21 ;VT_UI8 Else $DataTypeNu = 19 ;VT_UI4 EndIf ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Case "VBOOL" ;VARIANT_BOOL short A 16-bit ; ;(C++ 6.0 wtypes.h typedef short VARIANT_BOOL) [in,out] ([in] short) or ([out] short pointer (short*)) $DataTypeNu = 11 ;--------------------------------------------------------------------------------------------- Case "BSTR" ;[in,out] See SysAllocString Func ([in] A BSTR pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 8 Case "VARIANT" ;pointer Of VARIANT structure ;[in,out] ([in,out] VARIANT pointer Only) $DataTypeNu = 12 if Not($SafeArray_vt) Then $BOOLREF = True ; (Data Type Of VARIANT structure With ByRef Only) ;( Data Type Of $SafeArray_vt WithOut ByRef Only) See SafeArrayCreate Func Case "ARRAY" ; A SAFEARRAY pointer [in,out] ([in] SAFEARRAY pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 0x2000 Case "DISPATCH" ;Interface [in,out] ([in] DISPATCH pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 9 Case "UNKNOWN" ;Interface [in,out] ([in] UNKNOWN pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 13 Case "DATE" ;DATE See GetDoubleTime Func [in,out] ([in] double) or ([out] double pointer (double*)) $DataTypeNu = 7 Case "CY" ; Currency See GetCurrencyInt64 Func [in,out] ([in] INT64) or ([out] INT64 pointer (INT64*)) $DataTypeNu = 6 Case "ERROR" ;Scode [in,out] ([in] long) or ([out] long pointer (long*)) $DataTypeNu = 10 Case "DECIMAL" ;DECIMAL See GetDecimalSt Func / pointer Of DECIMAL structure ;[in,out] ([in,out] DECIMAL pointer Only) $DataTypeNu = 14 if Not($SafeArray_vt) Then $BOOLREF = True ; (Data Type Of DECIMAL structure With ByRef Only) ;( Data Type Of $SafeArray_vt WithOut ByRef Only) See SafeArrayCreate Func Case Else Return SetError(1,0,-1) EndSwitch if ($BOOLREF) Then $DataTypeNu = BitOR($VT_BYREF,$DataTypeNu) Return SetError(0,$BOOLREF,$DataTypeNu) EndFunc Func MakByRef($DataType = "ptr") Return DllStructCreate(String($DataType & " ByRef")) EndFunc Func GetByRefValue($ByRefSt) Return DllStructGetData($ByRefSt,1) EndFunc Func SetUnionOfVariant($VariantSt,$DataType,$Value) Return DllStructSetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1,$Value) EndFunc Func GetUnionOfVariant($VariantSt,$DataType) Return DllStructGetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1) EndFunc Func BstrToStr($BSTR,$FreeBstr = True) $BstrLen = SysStringLen($BSTR) if @error Then Return SetError(1,0,"") $StringSt = DllStructCreate("WCHAR[" & ($BstrLen + 1) & "]",$BSTR) $nString = DllStructGetData($StringSt,1) if ($FreeBstr) Then SysFreeString($BSTR) Return SetError(0,$BstrLen,$nString) EndFunc Func StrToBstr($String) Return SetError(@error,0,SysAllocString($String)) EndFunc Func SysAllocString($psz) Local $DataType = "PTR" if IsString($psz) Then $DataType = "WSTR" $BSTR = DllCall($OleAut32,"ptr","SysAllocString",$DataType,$psz) if @error Or $BSTR[0] = 0 Then Return SetError(1,0,0) Return $BSTR[0] ;BSTR Ptr EndFunc Func SysStringLen($psz) $UINT = DllCall($OleAut32,"UINT","SysStringLen","ptr",$psz) if @error Then Return SetError(1,0,0) Return $UINT[0] EndFunc Func SysFreeString($bstrString) DllCall($OleAut32,"none","SysFreeString","ptr",$bstrString) EndFunc Func GetSystemTime($DoubleTime) $lpSystemTime = DllStructCreate($vtagSYSTEMTIME) $BOOL = DllCall($OleAut32,"int","VariantTimeToSystemTime","DOUBLE",$DoubleTime,"struct*",$lpSystemTime) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Local $TimeArray[8][2] $TimeArray[0][1] = "Year" $TimeArray[0][0] = DllStructGetData($lpSystemTime,1) $TimeArray[1][1] = "Month" $TimeArray[1][0] = DllStructGetData($lpSystemTime,2) $TimeArray[2][1] = "DayOfWeek" $TimeArray[2][0] = DllStructGetData($lpSystemTime,3) $TimeArray[3][1] = "Day" $TimeArray[3][0] = DllStructGetData($lpSystemTime,4) $TimeArray[4][1] = "Hour" $TimeArray[4][0] = DllStructGetData($lpSystemTime,5) $TimeArray[5][1] = "Minute" $TimeArray[5][0] = DllStructGetData($lpSystemTime,6) $TimeArray[6][1] = "Secon" $TimeArray[6][0] = DllStructGetData($lpSystemTime,7) $TimeArray[7][1] = "Milliseconds" $TimeArray[7][0] = DllStructGetData($lpSystemTime,8) Return $TimeArray EndFunc Func GetDoubleTime($wYear,$wMonth,$wDayOfWeek,$wDay,$wHour,$wMinute,$wSecond,$wMilliseconds) $SYSTEMTIME = DllStructCreate($vtagSYSTEMTIME) DllStructSetData($SYSTEMTIME,1,$wYear) DllStructSetData($SYSTEMTIME,2,$wMonth) DllStructSetData($SYSTEMTIME,3,$wDayOfWeek) DllStructSetData($SYSTEMTIME,4,$wDay) DllStructSetData($SYSTEMTIME,5,$wHour) DllStructSetData($SYSTEMTIME,6,$wMinute) DllStructSetData($SYSTEMTIME,7,$wSecond) DllStructSetData($SYSTEMTIME,8,$wMilliseconds) $BOOL = DllCall($OleAut32,"int","SystemTimeToVariantTime","struct*",$SYSTEMTIME,"DOUBLE*",0) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) $DoubleTime = $BOOL[2] Return $DoubleTime EndFunc Func GetCurrencyInt64($Lo,$Hi) $StCY = DllStructCreate($tagCY) DllStructSetData($StCY,1,$Lo) DllStructSetData($StCY,2,$Hi) Return DllStructGetData(DllStructCreate("INT64",DllStructGetPtr($StCY)),1) EndFunc Func GetCurrencyStruct($Int64Value) $Int64ValueSt = DllStructCreate("INT64") DllStructSetData($Int64ValueSt,1,$Int64Value) $TempStCY = DllStructCreate($tagCY,DllStructGetPtr($Int64ValueSt)) $StCY = DllStructCreate($tagCY) DllStructSetData($StCY,1,DllStructGetData($TempStCY,1)) DllStructSetData($StCY,2,DllStructGetData($TempStCY,2)) Return $StCY EndFunc Func GetDecimalSt($scale,$sign,$Hi32,$Lo32,$Mid32) $DEC = DllStructCreate($tagDEC) DllStructSetData($DEC,2,$scale) DllStructSetData($DEC,3,$sign) DllStructSetData($DEC,4,$Hi32) DllStructSetData($DEC,5,$Lo32) DllStructSetData($DEC,6,$Mid32) Return $DEC EndFunc Func SafeArrayCreate($DataType,$cElements,$lLbound = 0) ;Array Manipulation Functions ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221145%28v=vs.85%29.aspx $vt = GetDataTypeNu($DataType,True) ;True $SafeArray_vt if @error Then Return SetError(1,0,0) if (@extended or $vt = 0x2000) Then Return SetError(2,0,0) ;(@extended VT_BYREF) (0x2000 VT_ARRAY ==> SAFEARRAY Data Type Number) $SAFEARRAY = DllCall($OleAut32,"ptr","SafeArrayCreate","USHORT",$vt,"UINT",1,"struct*",SABOUND($cElements,$lLbound)) if @error Or $SAFEARRAY[0] = 0 Then Return SetError(3,0,0) Return $SAFEARRAY[0] ;$vt or $DataTypeNu ;The base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the ;variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types ;for the array. All other types are legal. ;cElements ;The number of elements in the dimension. ;lLbound ;The lower bound of the dimension. EndFunc Func SABOUND($cElements,$lLbound) $SAFEARRAYBOUND = DllStructCreate($tagSAFEARRAYBOUND) DllStructSetData($SAFEARRAYBOUND,1,$cElements) DllStructSetData($SAFEARRAYBOUND,2,$lLbound) Return $SAFEARRAYBOUND EndFunc TypeInfo.au3 #include <WinAPI.au3> #include "DataType.au3" Func CreateDispTypeInfo($Struidata) $HRESULT = DllCall($OleAut32,"long","CreateDispTypeInfo","struct*",$Struidata,"DWORD",0,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) $pptinfo = $HRESULT[3] Return $pptinfo EndFunc Func MakeInterfacedata($cMembersCount) if $cMembersCount < 1 Then Return SetError(1,0,0) $AllocMethodData = GetAllocOfMethodsData($cMembersCount) if @error Then Return SetError(2,0,0) $StSize = DllStructGetSize(DllStructCreate($tagInterfacedata)) $LPVOID = CoTaskMemAlloc($StSize) $InterfacedataSt = DllStructCreate($tagInterfacedata,$LPVOID) DllStructSetData($InterfacedataSt,"MethodData",$AllocMethodData) DllStructSetData($InterfacedataSt,"cMembers",$cMembersCount) Return $InterfacedataSt EndFunc Func MakeMethodData(ByRef $InterfacedataSt,$MethodNumber,$MethodName,$ParametersCount,$ReturnType,$CALLCONV = $CC_STDCALL) if ($MethodName == "") Or (Not IsString($MethodName)) Then Return SetError(1,0,False) $vtReturn = GetDataTypeNu($ReturnType) If @error Then Return SetError(2,0,False) $cMembers = DllStructGetData($InterfacedataSt,"cMembers") if $ParametersCount > 30 or $ParametersCount < 0 or $MethodNumber > _ $cMembers Or $MethodNumber < 1 Then Return SetError(3,0,False) $MethodsData = DllStructGetData($InterfacedataSt,"MethodData") $MethodDataSt = GetStructOfMethodsData($MethodNumber,$MethodsData) if @error Then Return SetError(4,0,False) $MethodNameLen = StringLen($MethodName) $AllocszName = AllocFromStruct("WCHAR[" & ($MethodNameLen + 1) & "]") if @error Then Return SetError(5,0,False) $szNameSt = StructFromAlloc($AllocszName,"WCHAR[" & ($MethodNameLen + 1) & "]") if @error Then Return SetError(6,0,False) DllStructSetData($szNameSt,1,$MethodName) Local $ppdata = 0 if ($ParametersCount) Then $ppdata = GetAllocOfParamsData($ParametersCount) DllStructSetData($MethodDataSt,"szName",$AllocszName) ; Alloc METHOD name DllStructSetData($MethodDataSt,"ppdata",$ppdata) ; Alloc Parameters DllStructSetData($MethodDataSt,"dispid",$MethodNumber) ; METHOD Id start from 1 DllStructSetData($MethodDataSt,"iMeth",($MethodNumber - 1)) ;The index of the method in the VTBL start from 0 DllStructSetData($MethodDataSt,"cc",$CALLCONV) ; calling convention DllStructSetData($MethodDataSt,"cArgs",$ParametersCount) ; args for Parameters DllStructSetData($MethodDataSt,"wFlags",$DISPATCH_METHOD) ; METHOD Flag DllStructSetData($MethodDataSt,"vtReturn",$vtReturn) ;Number Of Return Type Return True EndFunc Func MakeParamData(ByRef $InterfacedataSt,$MethodNumber, $ParamType1 = 0,$ParamName1 = 0,$ParamType2 = 0,$ParamName2 = 0, _ $ParamType3 = 0 ,$ParamName3 = 0 , $ParamType4 = 0 , $ParamName4 = 0 , $ParamType5 = 0 , $ParamName5 = 0,$ParamType6 = 0, _ $ParamName6 = 0 ,$ParamType7 = 0 ,$ParamName7 = 0, $ParamType8 = 0 , $ParamName8 = 0 , $ParamType9 = 0 , $ParamName9 = 0, _ $ParamType10 = 0 ,$ParamName10 = 0 ,$ParamType11= 0 ,$ParamName11= 0 ,$ParamType12= 0 , $ParamName12= 0 ,$ParamType13= 0, _ $ParamName13 = 0 ,$ParamType14 = 0 ,$ParamName14 = 0 ,$ParamType15= 0 ,$ParamName15= 0 , $ParamType16= 0,$ParamName16= 0, _ $ParamType17= 0 ,$ParamName17 = 0 ,$ParamType18 = 0 ,$ParamName18 = 0 ,$ParamType19= 0 ,$ParamName19= 0 ,$ParamType20= 0, _ $ParamName20= 0 ,$ParamType21= 0 ,$ParamName21 = 0 ,$ParamType22 = 0 ,$ParamName22 = 0 ,$ParamType23= 0 ,$ParamName23= 0, _ $ParamType24= 0 ,$ParamName24= 0 ,$ParamType25= 0 ,$ParamName25 = 0 ,$ParamType26 = 0 ,$ParamName26 = 0 ,$ParamType27= 0, _ $ParamName27= 0 , $ParamType28= 0 ,$ParamName28= 0 ,$ParamType29= 0 ,$ParamName29 = 0 ,$ParamType30 = 0,$ParamName30 = 0 ) Local $ParametersCount = ((@NumParams - 2)/2) if (@NumParams > 2) And (Mod((@NumParams - 2),2) <> 0) Then Return SetError(1,0,False) $cMembers = DllStructGetData($InterfacedataSt,"cMembers") if $MethodNumber > $cMembers Or $MethodNumber < 1 Then Return SetError(2,0,False) $MethodsData = DllStructGetData($InterfacedataSt,"MethodData") $MethodDataSt = GetStructOfMethodsData($MethodNumber,$MethodsData) if @error Then Return SetError(3,0,False) $cArgs = DllStructGetData($MethodDataSt,"cArgs") if ($cArgs <> $ParametersCount) Then Return SetError(4,0,False) if $ParametersCount = 0 And $cArgs = 0 Then Return True $ppdata = DllStructGetData($MethodDataSt,"ppdata") ; Test Loop For $i = 1 To $ParametersCount $ParamType = Eval("ParamType" & $i) $ParamName = Eval("ParamName" & $i) GetDataTypeNu($ParamType) if @error Then Return SetError(5,0,False) if ($ParamName == "" Or (Not IsString($ParamName))) Then Return SetError(6,0,False) $ParamDataSt = GetStructOfParamsData($ppdata,$i) if @error Then Return SetError(7,0,False) Next For $i = 1 To $ParametersCount $ParamType = Eval("ParamType" & $i) $ParamTypeNu = GetDataTypeNu($ParamType) $ParamName = Eval("ParamName" & $i) $ParamNameLen = StringLen($ParamName) $AllocName = AllocFromStruct("WCHAR[" & ($ParamNameLen + 1) & "]") $szNameSt = StructFromAlloc($AllocName,"WCHAR[" & ($ParamNameLen + 1) & "]") DllStructSetData($szNameSt,1,$ParamName) $ParamDataSt = GetStructOfParamsData($ppdata,$i) DllStructSetData($ParamDataSt,"szName",$AllocName) ; Alloc Param name DllStructSetData($ParamDataSt,"vt",$ParamTypeNu) ;Number Of Param Type Next Return True EndFunc Func GetAllocOfMethodsData($cMembers) if $cMembers < 1 Then Return SetError(1,0,0) $MethodsDataSize = (DllStructGetSize(DllStructCreate($tagMethodData)) * $cMembers) if Not($MethodsDataSize) Then Return SetError(2,0,0) $LPVOID = CoTaskMemAlloc($MethodsDataSize) Return $LPVOID EndFunc Func GetStructOfMethodsData($MethodNumber,$ArrayhLock) if $MethodNumber < 1 Then Return SetError(1,0,0) $MethodDataSize = DllStructGetSize(DllStructCreate($tagMethodData)) $MethodsDataSt = DllStructCreate($tagMethodData,$ArrayhLock + ($MethodDataSize * ($MethodNumber - 1))) if Not IsDllStruct($MethodsDataSt) Then Return SetError(2,0,0) Return $MethodsDataSt EndFunc Func GetAllocOfParamsData($cArgs) if $cArgs < 1 Then Return SetError(1,0,0) $ParamsDataSize = (DllStructGetSize(DllStructCreate($tagParamData)) * $cArgs) if Not($ParamsDataSize) Then Return SetError(2,0,0) $LPVOID = CoTaskMemAlloc($ParamsDataSize) Return $LPVOID EndFunc Func GetStructOfParamsData($ArrayhLock,$ParamNumber) if $ParamNumber < 1 Then Return SetError(1,0,0) $ParamDataSize = DllStructGetSize(DllStructCreate($tagParamData)) $ParamsDataSt = DllStructCreate($tagParamData,$ArrayhLock + ($ParamDataSize * ($ParamNumber - 1))) if Not IsDllStruct($ParamsDataSt) Then Return SetError(2,0,0) Return $ParamsDataSt EndFunc Func AllocFromStruct($tagSt) $StSize = DllStructGetSize(DllStructCreate($tagSt)) if Not ($StSize) Then Return SetError(1,0,0) $LPVOID = CoTaskMemAlloc($StSize) Return $LPVOID EndFunc Func StructFromAlloc($hLock,$tagSt) $NewSt = DllStructCreate($tagSt,$hLock) if Not IsDllStruct($NewSt) Then Return SetError(1,0,0) Return $NewSt EndFunc Func CoTaskMemAlloc($cb) $LPVOID = DllCall($Ole32,"ptr","CoTaskMemAlloc","int",$cb) if @error Or $LPVOID[0] = 0 Then Return SetError(1,0,0) Return $LPVOID[0] EndFunc Func CoTaskMemFree($pv) DllCall($Ole32,"NONE","CoTaskMemFree","ptr",$pv) EndFunc Constants.au3 #include-once #include <WinAPI.au3> Global $Ole32 = DllOpen("Ole32.dll") Global $OleAut32 = DllOpen("OleAut32.dll") Global $Kernel32 = DllOpen("Kernel32.dll") Global $tagVariant = "USHORT vt;WORD wReserved1;WORD wReserved2;WORD wReserved3;byte union[8]" Global $tagDISPPARAMS = "ptr rgvarg;ptr rgdispidNamedArgs;UINT cArgs;UINT cNamedArgs" Global $tagMethodData = "ptr szName;ptr ppdata;UINT dispid;UINT iMeth;UINT cc;UINT cArgs;WORD wFlags;WORD vtReturn;" Global $tagParamData = "ptr szName;WORD vt;" Global $tagInterfacedata = "ptr MethodData;UINT cMembers" Global $vtagSYSTEMTIME = "WORD wYear;WORD wMonth;WORD wDayOfWeek;WORD wDay;WORD wHour;WORD wMinute;" & _ "WORD wSecond;WORD wMilliseconds" Global $tagCY = "ULONG Lo;long Hi" Global $tagDEC = "USHORT wReserved;BYTE scale;BYTE sign;ULONG Hi32;ULONG Lo32;ULONG Mid32;" Global $tagSAFEARRAYBOUND = "ULONG cElements;LONG lLbound" Global $tagnGUID = "ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" Global $VariantSize = DllStructGetSize(DllStructCreate($tagVariant)) Global $SizeOfUlong_Ptr = DllStructGetSize(DllStructCreate("ULONG_PTR")) Global $IID_NULL = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") Global $StOfClassArray[1][4] ; flags for RegisterActiveObject Global $ACTIVEOBJECT_STRONG = 0x0 Global $ACTIVEOBJECT_WEAK = 0x1 ;wFlags MemberType Global $DISPATCH_METHOD = 0x1, _ $DISPATCH_PROPERTYGET = 0x2 , _ $DISPATCH_PROPERTYPUT = 0x4 , _ $DISPATCH_PROPERTYPUTREF = 0x8 ;wFlags MemberType ;enum $tagCALLCONV Global $CC_FASTCALL = 0 Global $CC_CDECL = 1 Global $CC_MSCPASCAL = $CC_CDECL + 1 Global $CC_PASCAL = $CC_MSCPASCAL Global $CC_MACPASCAL = $CC_PASCAL + 1 Global $CC_STDCALL = $CC_MACPASCAL + 1 Global $CC_FPFASTCALL = $CC_STDCALL + 1 Global $CC_SYSCALL = $CC_FPFASTCALL + 1 Global $CC_MPWCDECL = $CC_SYSCALL + 1 Global $CC_MPWPASCAL = $CC_MPWCDECL + 1 Global $CC_MAX = $CC_MPWPASCAL + 1 ;enum $tagCALLCONV ;tagCLSCTX ;$dwClsContext Global $CLSCTX_INPROC_SERVER=0x1 , _ $CLSCTX_INPROC_HANDLER=0x2 , _ $CLSCTX_LOCAL_SERVER=0x4 , _ $CLSCTX_INPROC_SERVER16=0x8 , _ $CLSCTX_REMOTE_SERVER=0x10 , _ $CLSCTX_INPROC_HANDLER16=0x20 , _ $CLSCTX_RESERVED1=0x40 , _ $CLSCTX_RESERVED2=0x80 , _ $CLSCTX_RESERVED3=0x100 , _ $CLSCTX_RESERVED4=0x200 , _ $CLSCTX_NO_CODE_DOWNLOAD=0x400 , _ $CLSCTX_RESERVED5=0x800 , _ $CLSCTX_NO_CUSTOM_MARSHAL=0x1000 , _ $CLSCTX_ENABLE_CODE_DOWNLOAD=0x2000 , _ $CLSCTX_NO_FAILURE_LOG=0x4000 , _ $CLSCTX_DISABLE_AAA=0x8000 , _ $CLSCTX_ENABLE_AAA=0x10000 , _ $CLSCTX_FROM_DEFAULT_CONTEXT=0x20000 , _ $CLSCTX_ACTIVATE_32_BIT_SERVER=0x40000 , _ $CLSCTX_ACTIVATE_64_BIT_SERVER=0x80000 , _ $CLSCTX_ENABLE_CLOAKING=0x100000 , _ $CLSCTX_APPCONTAINER=0x400000 , _ $CLSCTX_ACTIVATE_AAA_AS_IU=0x800000 , _ $CLSCTX_PS_DLL=0x80000000 ;$dwClsContext ;tagCLSCTX ;tagREGCLS ;flags Global $REGCLS_SINGLEUSE = 0, _ $REGCLS_MULTIPLEUSE = 1, _ $REGCLS_MULTI_SEPARATE = 2, _ $REGCLS_SUSPENDED = 4, _ $REGCLS_SURROGATE = 8 ;flags ;tagREGCLS1 point -
Hi, _FileWriteFromArray now writes from both 1D and 2D arrays - so we thought it about time that _FileReadToArray could read both types as well. Here is a Beta version of the new function for testing and comments. A few points before starting: - 1. This function returns an array - there is no longer the need to pre-declare one and pass it as a parameter. - 2. The $iFlags parameter determines how the function proceeds: + 1 (works for both 1D and 2D arrays) adds a count in the top row - this is the default setting. + 2 (for 2D arrays only) Creates an "array of arrays" where each element contains the split line as an array. + 4. (only valid of you set a delimiter) works like the $STR_ENTIRESPLIT flag in StringSplit and uses all the delimiter characters as the split point. By default splits occur for each character. - 3. If you try to read a "non-square" file (one that does not have the same number of fields on each line) and do not set the 2 flag then the function returns an error. This is meant to act as an error check where an expected file format is not found. Have fun: #include <Array.au3> #include <File.au3> Global $aRetArray ; Create 1D array Global $aArray[] = ["0", "1", "2", "3", "4"] ; Write it to file _FileWriteFromArray("Test.txt", $aArray, Default, Default, @CRLF) Sleep(1000) ; Re-read it - with count $aRetArray = _FileReadToArray_New("Test.txt") ConsoleWrite("Error returned: " & @error & @CRLF) _ArrayDisplay($aRetArray, "1D array - count", Default, 8) ; Re-read it - without count $aRetArray = _FileReadToArray_New("Test.txt", 0) ConsoleWrite("Error returned: " & @error & @CRLF) _ArrayDisplay($aRetArray, "1D array - no count", Default, 8) ; Create "square" 2D array Global $aArray[][] = [ _ ["00", "01", "02", "03"], _ ["10", "11", "12", "13"], _ ["20", "21", "22", "23"], _ ["30", "31", "32", "33"]] _ArrayDisplay($aArray, "Original", Default, 8) ; Write it to file _FileWriteFromArray("Test.txt", $aArray, Default, Default, ",") Sleep(1000) ; Re-read it - with count $aRetArray = _FileReadToArray_New("Test.txt", Default, ",") ConsoleWrite("Error returned: " & @error & @CRLF) _ArrayDisplay($aRetArray, "2D array - count", Default, 8) ; Re-read it - without count $aRetArray = _FileReadToArray_New("Test.txt", 0, ",") ConsoleWrite("Error returned: " & @error & @CRLF) _ArrayDisplay($aRetArray, "2D array - no count", Default, 8) ; Read into "array of arrays" $aRetArray = _FileReadToArray_New("Test.txt", 2, ",") ConsoleWrite("Error returned: " & @error & @CRLF) _ArrayDisplay($aRetArray, "Array of arrays", Default, 8) ; Now look inside the arrays inside the returned array _ArrayDisplay($aRetArray[1], "Array 1 inside RetArray", Default, 8) ; Rewrite 2D array with multiple delimiters _FileWriteFromArray("Test.txt", $aArray, Default, Default, ":|") Sleep(1000) ; Re-read with each delimiter acting as a split point $aRetArray = _FileReadToArray_New("Test.txt", 0, ":|") ConsoleWrite("Error: " & @error & @CRLF) _ArrayDisplay($aRetArray, "Split on each character", Default, 8) ; Re-read with whole delimiter acting as a split point $aRetArray = _FileReadToArray_New("Test.txt", 4, ":|") ConsoleWrite("Error: " & @error & @CRLF) _ArrayDisplay($aRetArray, "Split on full delimiter", Default, 8) Func _FileReadToArray_New($sFilePath, $iFlags = 1, $sDelimiter = "") ; $iFlags: + 1 = Dimensions in top row (default) - 1D: [0] = rows ; 2D: [0][0]/[0][1] = rows/cols ; + 2 = Create 1D "array of arrays" allowing lines to have different numbers of fields ; + 4 = Use entire delimiter string as split point (default each character defines a split point) ; Error: 1 = Error opening specified file ; 2 = Empty file ; 3 = File not "square" and flag 2 not used ; 4 = No delimiters found If $iFlags = Default Then $iFlags = 1 If $sDelimiter = Default Then $sDelimiter = "" ; Set "array of arrays" flag Local $fExpand = True If BitAnd($iFlags, 2) Then $fExpand = False $iFlags -= 2 EndIf ; Set delimiter flag Local $iEntire = 0 ; $STR_CHRSPLIT If BitAnd($iFlags, 4) Then $iEntire = 1 ; $STR_ENTIRESPLIT $iFlags -= 4 EndIf ; Set row count and split count flags Local $iNoCount = 0 If $iFlags <> 1 Then $iFlags = 0 $iNoCount = 2 ; $STR_NOCOUNT EndIf ; Read file into an array Local $aLines = FileReadToArray($sFilePath) If @error Then Return SetError(@error, 0, 0) ; If 1D with no count return array directly If Not $iFlags And Not $sDelimiter Then Return $aLines ; Declare variables Local $aArray, $aSplit_2 ; Get first dimension and add count if required Local $iDim_1 = UBound($aLines) + $iFlags ; Check delimiter If $sDelimiter Then ; Check type of return array If $fExpand Then ; All lines have same number of fields Local $iFields ; Count fields in first line Local $iDim_2 = UBound(StringSplit($aLines[0], $sDelimiter, $iEntire + $STR_NOCOUNT)) ; Size array Local $aArray[$iDim_1][$iDim_2] ; Loop through the lines For $i = 0 To $iDim_1 - $iFlags - 1 ; Split each line as required $aSplit_2 = StringSplit($aLines[$i], $sDelimiter, $iEntire + $STR_NOCOUNT) ; Count the items $iFields = UBound($aSplit_2) If $iFields <> $iDim_2 Then ; Return error Return SetError(3, 0, 0) EndIf ; Fill this line of the array For $j = 0 To $iFields - 1 $aArray[$i + $iFlags][$j] = $aSplit_2[$j] Next Next ; Check at least 2 columns If $iDim_2 < 2 Then Return SetError(4, 0, 0) ; Set dimension count If $iFlags Then $aArray[0][0] = $iDim_1 - $iFlags $aArray[0][1] = $iDim_2 EndIf Else ; Create "array of arrays" ; Size array Local $aArray[$iDim_1] ; Loop through the lines For $i = 0 To $iDim_1 - $iFlags - 1 ; Split each line as required $aArray[$i + $iFlags] = StringSplit($aLines[$i], $sDelimiter, $iEntire + $iNoCount) Next ; Set dimension count If $iFlags Then $aArray[0] = $iDim_1 - $iFlags EndIf EndIf Else ; 1D ; Declare array of correct size and set count Local $aArray[UBound($aLines) + 1] = [UBound($aArray) - 1] ; Copy data For $i = 0 To UBound($aLines) - 1 $aArray[$i + 1] = $aLines[$i] Next EndIf ; Return the array Return $aArray EndFunc If you break the function or the returned array is not what you expected, please post the SciTE output pane, the calling line and the file concerned so that I can debug it. M231 point
-
An UDF for retrieving MIME types based on the extension of the filename/filepath/URL provided. Features: - contains DB of strict IANA MIMEs - contains DB of non-strict IANA MIMEs - can retrieve MIMEs from the Windows Registery - can create MIME based on the filetype found in the Windows Registery - can create MIME based on the extension (basically just prepends "application/x-") - all resources above can be combined independently - query time is between 0.5 - 1.5 ms (up to 2 ms on the first execution) #include-once ;~ #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 ; Example ; ==================================================================================================================== ;~ Local $iNumOfTests = 10000, $t = TimerInit(), $sFile = "sds.au3" ;~ For $i = 1 To $iNumOfTests ;~ __WinHttpMIMEType($sFile) ;~ Next ;~ ConsoleWrite("The speed of __WinHttpMIMEType is: " & Round(TimerDiff($t) / $iNumOfTests, 3) & " ms per query (IANA-strict)" & @CRLF) ;~ ConsoleWrite(@TAB & " resolves to: " & __WinHttpMIMEType($sFile) & @CRLF) ;~ $t = TimerInit() ;~ For $i = 1 To $iNumOfTests ;~ _FileGetMimeType($sFile) ;~ Next ;~ ConsoleWrite("The speed of _FileGetMimeType is: " & Round(TimerDiff($t) / $iNumOfTests, 3) & " ms per query (IANA-strict)" & @CRLF) ;~ ConsoleWrite(@TAB & " resolves to: " & _FileGetMimeType($sFile) & @CRLF) ;~ $t = TimerInit() ;~ For $i = 1 To $iNumOfTests ;~ _FileGetMimeType($sFile, 15) ;~ Next ;~ ConsoleWrite("The speed of _FileGetMimeType is: " & Round(TimerDiff($t) / $iNumOfTests, 3) & " ms per query (IANA-non-strict all options enabled)" & @CRLF) ;~ ConsoleWrite(@TAB & " resolves to: " & _FileGetMimeType($sFile, 15) & @CRLF) ;~ Func __WinHttpMIMEType($sFileName) ;~ Local $aArray = StringRegExp(__WinHttpMIMEAssocString(), "(?i)\Q;" & StringRegExpReplace($sFileName, ".*\.", "") & "\E\|(.*?);", 3) ;~ If @error Then Return "application/octet-stream" ;~ Return $aArray[0] ;~ EndFunc ;==>__WinHttpMIMEType ;~ Func __WinHttpMIMEAssocString() ;~ Return ";ai|application/postscript;aif|audio/x-aiff;aifc|audio/x-aiff;aiff|audio/x-aiff;asc|text/plain;atom|application/atom+xml;au|audio/basic;avi|video/x-msvideo;bcpio|application/x-bcpio;bin|application/octet-stream;bmp|image/bmp;cdf|application/x-netcdf;cgm|image/cgm;class|application/octet-stream;cpio|application/x-cpio;cpt|application/mac-compactpro;csh|application/x-csh;css|text/css;dcr|application/x-director;dif|video/x-dv;dir|application/x-director;djv|image/vnd.djvu;djvu|image/vnd.djvu;dll|application/octet-stream;dmg|application/octet-stream;dms|application/octet-stream;doc|application/msword;dtd|application/xml-dtd;dv|video/x-dv;dvi|application/x-dvi;dxr|application/x-director;eps|application/postscript;etx|text/x-setext;exe|application/octet-stream;ez|application/andrew-inset;gif|image/gif;gram|application/srgs;grxml|application/srgs+xml;gtar|application/x-gtar;hdf|application/x-hdf;hqx|application/mac-binhex40;htm|text/html;html|text/html;ice|x-conference/x-cooltalk;ico|image/x-icon;ics|text/calendar;ief|image/ief;ifb|text/calendar;iges|model/iges;igs|model/iges;jnlp|application/x-java-jnlp-file;jp2|image/jp2;jpe|image/jpeg;jpeg|image/jpeg;jpg|image/jpeg;js|application/x-javascript;kar|audio/midi;latex|application/x-latex;lha|application/octet-stream;lzh|application/octet-stream;m3u|audio/x-mpegurl;m4a|audio/mp4a-latm;m4b|audio/mp4a-latm;m4p|audio/mp4a-latm;m4u|video/vnd.mpegurl;m4v|video/x-m4v;mac|image/x-macpaint;man|application/x-troff-man;mathml|application/mathml+xml;me|application/x-troff-me;mesh|model/mesh;mid|audio/midi;midi|audio/midi;mif|application/vnd.mif;mov|video/quicktime;movie|video/x-sgi-movie;mp2|audio/mpeg;mp3|audio/mpeg;mp4|video/mp4;mpe|video/mpeg;mpeg|video/mpeg;mpg|video/mpeg;mpga|audio/mpeg;ms|application/x-troff-ms;msh|model/mesh;mxu|video/vnd.mpegurl;nc|application/x-netcdf;oda|application/oda;ogg|application/ogg;pbm|image/x-portable-bitmap;pct|image/pict;pdb|chemical/x-pdb;pdf|application/pdf;pgm|image/x-portable-graymap;pgn|application/x-chess-pgn;pic|image/pict;pict|image/pict;png|image/png;pnm|image/x-portable-anymap;pnt|image/x-macpaint;pntg|image/x-macpaint;ppm|image/x-portable-pixmap;ppt|application/vnd.ms-powerpoint;ps|application/postscript;qt|video/quicktime;qti|image/x-quicktime;qtif|image/x-quicktime;ra|audio/x-pn-realaudio;ram|audio/x-pn-realaudio;ras|image/x-cmu-raster;rdf|application/rdf+xml;rgb|image/x-rgb;rm|application/vnd.rn-realmedia;roff|application/x-troff;rtf|text/rtf;rtx|text/richtext;sgm|text/sgml;sgml|text/sgml;sh|application/x-sh;shar|application/x-shar;silo|model/mesh;sit|application/x-stuffit;skd|application/x-koan;skm|application/x-koan;skp|application/x-koan;skt|application/x-koan;smi|application/smil;smil|application/smil;snd|audio/basic;so|application/octet-stream;spl|application/x-futuresplash;src|application/x-wais-source;sv4cpio|application/x-sv4cpio;sv4crc|application/x-sv4crc;svg|image/svg+xml;swf|application/x-shockwave-flash;t|application/x-troff;tar|application/x-tar;tcl|application/x-tcl;tex|application/x-tex;texi|application/x-texinfo;texinfo|application/x-texinfo;tif|image/tiff;tiff|image/tiff;tr|application/x-troff;tsv|text/tab-separated-values;txt|text/plain;ustar|application/x-ustar;vcd|application/x-cdlink;vrml|model/vrml;vxml|application/voicexml+xml;wav|audio/x-wav;wbmp|image/vnd.wap.wbmp;wbmxl|application/vnd.wap.wbxml;wml|text/vnd.wap.wml;wmlc|application/vnd.wap.wmlc;wmls|text/vnd.wap.wmlscript;wmlsc|application/vnd.wap.wmlscriptc;wrl|model/vrml;xbm|image/x-xbitmap;xht|application/xhtml+xml;xhtml|application/xhtml+xml;xls|application/vnd.ms-excel;xml|application/xml;xpm|image/x-xpixmap;xsl|application/xml;xslt|application/xslt+xml;xul|application/vnd.mozilla.xul+xml;xwd|image/x-xwindowdump;xyz|chemical/x-xyz;zip|application/zip;" ;~ EndFunc ;==>__WinHttpMIMEAssocString ; Example ==================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileGetMimeType ; Description ...: ; Syntax ........: _FileGetMimeType($sFileName[, $iOptions = 0[, $sDefaultMimeType = "application/octet-stream"]]) ; Parameters ....: $sFileName - A string value. ; $iOptions - [optional] An integer value. Default is 0. Options driving the behaviour of the resolving of the MIME. ; Any combination of the following values: ; 0 - IANA strict DB ; 1 - IANA non-strict DB ; 2 - Windows Registery ; 4 - Guess from the file type in the Windows Registery ; 8 - Guess just from the extension ; $sDefaultMimeType - [optional] A string value. Default is "application/octet-stream". ; A Default MIME that will be returned if none was found. ; Return values .: Success - A valid mime type. (valid as much as your options allowed) ; Failure - The default mime type and if the filename has had no extension then sets @error to non-zero ; Author ........: rindeal ; Modified ......: ; Remarks .......: RegEx DB search provided by trancexx's __WinHttpMIMEType ; Related .......: __WinHttpMIMEType ; Link ..........: ; Example .......: yes ; =============================================================================================================================== Func _FileGetMimeType($sFileName, $iOptions = 0, $sDefaultMimeType = "application/octet-stream") ; in the worst case it takes about 0.12 - 0.14 ms to proceed If Not StringInStr($sFileName, ".", 2) Then Return SetError(1, 0, $sDefaultMimeType) Local $sExtension, $aArray, $sMimeType, $sFileType $sExtension = StringRegExp($sFileName, "(?i)\.([^\\/.?=@]+)[^.]*$", 3)[0] $aArray = StringRegExp(__FileGetMimeType_GetDB(BitAND(1, $iOptions)), "(?i)\Q|" & $sExtension & "\E;(.*?)\|", 3) If Not @error Then Return $aArray[0] If BitAND(2, $iOptions) Then $sMimeType = RegRead('HKCR\.' & $sExtension, 'Content Type') If Not @error Then Return $sMimeType EndIf If BitAND(4, $iOptions) Then $sFileType = RegRead('HKCR\.' & $sExtension, 'PerceivedType') If Not @error Then Return $sFileType & '/x-' & $sExtension EndIf If BitAND(8, $iOptions) Then Return "application/x-" & $sExtension EndIf Return $sDefaultMimeType EndFunc ;==>_FileGetMimeType ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __FileGetMimeType_GetDB ; Description ...: Reurns a string that will be passed to a DB search function ; Syntax ........: __FileGetMimeType_GetDB([$iIANA_NonStrict = False]) ; Parameters ....: $iIANA_NonStrict - [optional] An integer value. Default is False. ; Set to true if IANA non-strict MIMEs should be returned as well ; Return values .: A string that will be passed to a DB search function ; Author ........: rindeal ; Modified ......: guiness ; Remarks .......: Initial idea and IANA strict DB from trancexx's __WinHttpMIMEAssocString() ; Related .......: __WinHttpMIMEAssocString() ; Link ..........: http://www.stdicon.com/mimetypes ; Example .......: No ; =============================================================================================================================== Func __FileGetMimeType_GetDB($iIANA_NonStrict = False) ; binarysearch is slower for small DBs, but much faster for bigger DBs (5k+ rows) ; this has 850+ rows, therefore stringregexp is simpler to implement and maintain Local Static $sIANA_NonStrict = "" Local Static $sIANA_Strict = "|ai;application/postscript|aif;audio/x-aiff|aifc;audio/x-aiff|aiff;audio/x-aiff|asc;text/plain|atom;application/atom+xml|au;audio/basic|avi;video/x-msvideo|bcpio;application/x-bcpio|bin;application/octet-stream|bmp;image/bmp|cdf;application/x-netcdf|cgm;image/cgm|class;application/octet-stream|cpio;application/x-cpio|cpt;application/mac-compactpro|csh;application/x-csh|css;text/css|dcr;application/x-director|dif;video/x-dv|dir;application/x-director|djv;image/vnd.djvu|djvu;image/vnd.djvu|dll;application/octet-stream|dmg;application/octet-stream|dms;application/octet-stream|doc;application/msword|dtd;application/xml-dtd|dv;video/x-dv|dvi;application/x-dvi|dxr;application/x-director|eps;application/postscript|etx;text/x-setext|exe;application/octet-stream|ez;application/andrew-inset|gif;image/gif|gram;application/srgs|grxml;application/srgs+xml|gtar;application/x-gtar|hdf;application/x-hdf|hqx;application/mac-binhex40|htm;text/html|html;text/html|ice;x-conference/x-cooltalk|ico;image/x-icon|ics;text/calendar|ief;image/ief|ifb;text/calendar|iges;model/iges|igs;model/iges|jnlp;application/x-java-jnlp-file|jp2;image/jp2|jpe;image/jpeg|jpeg;image/jpeg|jpg;image/jpeg|js;application/x-javascript|kar;audio/midi|latex;application/x-latex|lha;application/octet-stream|lzh;application/octet-stream|m3u;audio/x-mpegurl|m4a;audio/mp4a-latm|m4b;audio/mp4a-latm|m4p;audio/mp4a-latm|m4u;video/vnd.mpegurl|m4v;video/x-m4v|mac;image/x-macpaint|man;application/x-troff-man|mathml;application/mathml+xml|me;application/x-troff-me|mesh;model/mesh|mid;audio/midi|midi;audio/midi|mif;application/vnd.mif|mov;video/quicktime|movie;video/x-sgi-movie|mp2;audio/mpeg|mp3;audio/mpeg|mp4;video/mp4|mpe;video/mpeg|mpeg;video/mpeg|mpg;video/mpeg|mpga;audio/mpeg|ms;application/x-troff-ms|msh;model/mesh|mxu;video/vnd.mpegurl|nc;application/x-netcdf|oda;application/oda|ogg;application/ogg|pbm;image/x-portable-bitmap|pct;image/pict|" If Not $sIANA_NonStrict Then $sIANA_Strict &= "pdb;chemical/x-pdb|pdf;application/pdf|pgm;image/x-portable-graymap|pgn;application/x-chess-pgn|pic;image/pict|pict;image/pict|png;image/png|pnm;image/x-portable-anymap|pnt;image/x-macpaint|pntg;image/x-macpaint|ppm;image/x-portable-pixmap|ppt;application/vnd.ms-powerpoint|ps;application/postscript|qt;video/quicktime|qti;image/x-quicktime|qtif;image/x-quicktime|ra;audio/x-pn-realaudio|ram;audio/x-pn-realaudio|ras;image/x-cmu-raster|rdf;application/rdf+xml|rgb;image/x-rgb|rm;application/vnd.rn-realmedia|roff;application/x-troff|rtf;text/rtf|rtx;text/richtext|sgm;text/sgml|sgml;text/sgml|sh;application/x-sh|shar;application/x-shar|silo;model/mesh|sit;application/x-stuffit|skd;application/x-koan|skm;application/x-koan|skp;application/x-koan|skt;application/x-koan|smi;application/smil|smil;application/smil|snd;audio/basic|so;application/octet-stream|spl;application/x-futuresplash|src;application/x-wais-source|sv4cpio;application/x-sv4cpio|sv4crc;application/x-sv4crc|svg;image/svg+xml|swf;application/x-shockwave-flash|t;application/x-troff|tar;application/x-tar|tcl;application/x-tcl|tex;application/x-tex|texi;application/x-texinfo|texinfo;application/x-texinfo|tif;image/tiff|tiff;image/tiff|tr;application/x-troff|tsv;text/tab-separated-values|txt;text/plain|ustar;application/x-ustar|vcd;application/x-cdlink|vrml;model/vrml|vxml;application/voicexml+xml|wav;audio/x-wav|wbmp;image/vnd.wap.wbmp|wbmxl;application/vnd.wap.wbxml|wml;text/vnd.wap.wml|wmlc;application/vnd.wap.wmlc|wmls;text/vnd.wap.wmlscript|wmlsc;application/vnd.wap.wmlscriptc|wrl;model/vrml|xbm;image/x-xbitmap|xht;application/xhtml+xml|xhtml;application/xhtml+xml|xls;application/vnd.ms-excel|xml;application/xml|xpm;image/x-xpixmap|xsl;application/xml|xslt;application/xslt+xml|xul;application/vnd.mozilla.xul+xml|xwd;image/x-xwindowdump|xyz;chemical/x-xyz|zip;application/zip|" $sIANA_NonStrict = ".123;application/vnd.lotus-1-2-3|3dml;text/vnd.in3d.3dml|3g2;video/3gpp2|3gp;video/3gpp|aab;application/x-authorware-bin|aac;audio/x-aac|aam;application/x-authorware-map|a;application/octet-stream|aas;application/x-authorware-seg|abw;application/x-abiword|acc;application/vnd.americandynamics.acc|ace;application/x-ace-compressed|acu;application/vnd.acucobol|acutc;application/vnd.acucorp|adp;audio/adpcm|aep;application/vnd.audiograph|afm;application/x-font-type1|afp;application/vnd.ibm.modcap|air;application/vnd.adobe.air-application-installer-package+zip|ami;application/vnd.amiga.ami|apk;application/vnd.android.package-archive|application;application/x-ms-application|apr;application/vnd.lotus-approach|asc;application/pgp-signature|asc;text/plain|asf;video/x-ms-asf|asm;text/x-asm|aso;application/vnd.accpac.simply.aso|asx;video/x-ms-asf|atc;application/vnd.acucorp|atomcat;application/atomcat+xml|atomsvc;application/atomsvc+xml|atx;application/vnd.antix.game-component|aw;application/applixware|azf;application/vnd.airzip.filesecure.azf|azs;application/vnd.airzip.filesecure.azs|azw;application/vnd.amazon.ebook|bat;application/x-msdownload|bdf;application/x-font-bdf|bdm;application/vnd.syncml.dm+wbxml|bh2;application/vnd.fujitsu.oasysprs|bmi;application/vnd.bmi|book;application/vnd.framemaker|box;application/vnd.previewsystems.box|boz;application/x-bzip2|bpk;application/octet-stream|btif;image/prs.btif|bz2;application/x-bzip2|bz;application/x-bzip|c4d;application/vnd.clonk.c4group|c4f;application/vnd.clonk.c4group|c4g;application/vnd.clonk.c4group|c4p;application/vnd.clonk.c4group|c4u;application/vnd.clonk.c4group|cab;application/vnd.ms-cab-compressed|car;application/vnd.curl.car|cat;application/vnd.ms-pki.seccat|cct;application/x-director|cc;text/x-c|ccxml;application/ccxml+xml|cdbcmsg;application/vnd.contact.cmsg|cdkey;application/vnd.mediastation.cdkey|cdx;chemical/x-cdx|cdxml;application/vnd.chemdraw+xml|cdy;application/vnd.cinderella|cer;application/pkix-cert|chat;application/x-chat|chm;application/vnd.ms-htmlhelp|" $sIANA_NonStrict &= "chrt;application/vnd.kde.kchart|cif;chemical/x-cif|cii;application/vnd.anser-web-certificate-issue-initiation|cil;application/vnd.ms-artgalry|cla;application/vnd.claymore|clkk;application/vnd.crick.clicker.keyboard|clkp;application/vnd.crick.clicker.palette|clkt;application/vnd.crick.clicker.template|clkw;application/vnd.crick.clicker.wordbank|clkx;application/vnd.crick.clicker|clp;application/x-msclip|cmc;application/vnd.cosmocaller|cmdf;chemical/x-cmdf|cml;chemical/x-cml|cmp;application/vnd.yellowriver-custom-menu|cmx;image/x-cmx|cod;application/vnd.rim.cod|com;application/x-msdownload|conf;text/plain|cpp;text/x-c|crd;application/x-mscardfile|crl;application/pkix-crl|crt;application/x-x509-ca-cert|csml;chemical/x-csml|csp;application/vnd.commonspace|cst;application/x-director|csv;text/csv|c;text/x-c|cu;application/cu-seeme|curl;text/vnd.curl|cww;application/prs.cww|cxt;application/x-director|cxx;text/x-c|daf;application/vnd.mobius.daf|dataless;application/vnd.fdsn.seed|davmount;application/davmount+xml|dcurl;text/vnd.curl.dcurl|dd2;application/vnd.oma.dd2+xml|ddd;application/vnd.fujixerox.ddd|deb;application/x-debian-package|def;text/plain|deploy;application/octet-stream|der;application/x-x509-ca-cert|dfac;application/vnd.dreamfactory|dic;text/x-c|diff;text/plain|dif;video/x-dv|dis;application/vnd.mobius.dis|dist;application/octet-stream|distz;application/octet-stream|dna;application/vnd.dna|docm;application/vnd.ms-word.document.macroenabled.12|docx;application/vnd.openxmlformats-officedocument.wordprocessingml.document|dot;application/msword|dotm;application/vnd.ms-word.template.macroenabled.12|dotx;application/vnd.openxmlformats-officedocument.wordprocessingml.template|dp;application/vnd.osgi.dp|dpg;application/vnd.dpgraph|dsc;text/prs.lines.tag|dtb;application/x-dtbook+xml|dts;audio/vnd.dts|dtshd;audio/vnd.dts.hd|dump;application/octet-stream|dv;video/x-dv|dwf;model/vnd.dwf|dwg;image/vnd.dwg|dxf;image/vnd.dxf|dxp;application/vnd.spotfire.dxp|ecma;application/ecmascript|edm;application/vnd.novadigm.edm|" $sIANA_NonStrict &= "edx;application/vnd.novadigm.edx|efif;application/vnd.picsel|ei6;application/vnd.pg.osasli|elc;application/octet-stream|eml;message/rfc822|emma;application/emma+xml|eol;audio/vnd.digital-winds|eot;application/vnd.ms-fontobject|epub;application/epub+zip|es3;application/vnd.eszigno3+xml|esf;application/vnd.epson.esf|et3;application/vnd.eszigno3+xml|ext;application/vnd.novadigm.ext|ez2;application/vnd.ezpix-album|ez3;application/vnd.ezpix-package|f4v;video/x-f4v|f77;text/x-fortran|f90;text/x-fortran|fbs;image/vnd.fastbidsheet|fdf;application/vnd.fdf|fe_launch;application/vnd.denovo.fcselayout-link|fg5;application/vnd.fujitsu.oasysgp|fgd;application/x-director|fh4;image/x-freehand|fh5;image/x-freehand|fh7;image/x-freehand|fhc;image/x-freehand|fh;image/x-freehand|fig;application/x-xfig|fli;video/x-fli|flo;application/vnd.micrografx.flo|flv;video/x-flv|flw;application/vnd.kde.kivio|flx;text/vnd.fmi.flexstor|fly;text/vnd.fly|fm;application/vnd.framemaker|fnc;application/vnd.frogans.fnc|for;text/x-fortran|fpx;image/vnd.fpx|frame;application/vnd.framemaker|fsc;application/vnd.fsc.weblaunch|fst;image/vnd.fst|ftc;application/vnd.fluxtime.clip|f;text/x-fortran|fti;application/vnd.anser-web-funds-transfer-initiation|fvt;video/vnd.fvt|fzs;application/vnd.fuzzysheet|g3;image/g3fax|gac;application/vnd.groove-account|gdl;model/vnd.gdl|geo;application/vnd.dynageo|gex;application/vnd.geometry-explorer|ggb;application/vnd.geogebra.file|ggt;application/vnd.geogebra.tool|ghf;application/vnd.groove-help|gim;application/vnd.groove-identity-message|gmx;application/vnd.gmx|gnumeric;application/x-gnumeric|gph;application/vnd.flographit|gqf;application/vnd.grafeq|gqs;application/vnd.grafeq|gre;application/vnd.geometry-explorer|grv;application/vnd.groove-injector|gsf;application/x-font-ghostscript|gtm;application/vnd.groove-tool-message|gtw;model/vnd.gtw|gv;text/vnd.graphviz|gz;application/x-gzip|h261;video/h261|h263;video/h263|h264;video/h264|hbci;application/vnd.hbci|hh;text/x-c|hlp;application/winhlp|hpgl;application/vnd.hp-hpgl|" $sIANA_NonStrict &= "hpid;application/vnd.hp-hpid|hps;application/vnd.hp-hps|h;text/x-c|htke;application/vnd.kenameaapp|hvd;application/vnd.yamaha.hv-dic|hvp;application/vnd.yamaha.hv-voice|hvs;application/vnd.yamaha.hv-script|icc;application/vnd.iccprofile|icm;application/vnd.iccprofile|ifm;application/vnd.shana.informed.formdata|igl;application/vnd.igloader|igx;application/vnd.micrografx.igx|iif;application/vnd.shana.informed.interchange|imp;application/vnd.accpac.simply.imp|ims;application/vnd.ms-ims|in;text/plain|ipk;application/vnd.shana.informed.package|irm;application/vnd.ibm.rights-management|irp;application/vnd.irepository.package+xml|iso;application/octet-stream|itp;application/vnd.shana.informed.formtemplate|ivp;application/vnd.immervision-ivp|ivu;application/vnd.immervision-ivu|jad;text/vnd.sun.j2me.app-descriptor|jam;application/vnd.jam|jar;application/java-archive|java;text/x-java-source|jisp;application/vnd.jisp|jlt;application/vnd.hp-jlyt|joda;application/vnd.joost.joda-archive|jp2;image/jp2|jpgm;video/jpm|jpgv;video/jpeg|jpm;video/jpm|json;application/json|karbon;application/vnd.kde.karbon|kfo;application/vnd.kde.kformula|kia;application/vnd.kidspiration|kil;application/x-killustrator|kml;application/vnd.google-earth.kml+xml|kmz;application/vnd.google-earth.kmz|kne;application/vnd.kinar|knp;application/vnd.kinar|kon;application/vnd.kde.kontour|kpr;application/vnd.kde.kpresenter|kpt;application/vnd.kde.kpresenter|ksh;text/plain|ksp;application/vnd.kde.kspread|ktr;application/vnd.kahootz|ktz;application/vnd.kahootz|kwd;application/vnd.kde.kword|kwt;application/vnd.kde.kword|lbd;application/vnd.llamagraphics.life-balance.desktop|lbe;application/vnd.llamagraphics.life-balance.exchange+xml|les;application/vnd.hhe.lesson-player|link66;application/vnd.route66.link66+xml|list3820;application/vnd.ibm.modcap|listafp;application/vnd.ibm.modcap|list;text/plain|log;text/plain|lostxml;application/lost+xml|lrf;application/octet-stream|lrm;application/vnd.ms-lrm|ltf;application/vnd.frogans.ltf|lvp;audio/vnd.lucent.voice|" $sIANA_NonStrict &= "lwp;application/vnd.lotus-wordpro|m13;application/x-msmediaview|m14;application/x-msmediaview|m1v;video/mpeg|m2a;audio/mpeg|m2v;video/mpeg|m3a;audio/mpeg|m4a;audio/mp4a-latm|m4b;audio/mp4a-latm|m4p;audio/mp4a-latm|ma;application/mathematica|mac;image/x-macpaint|mag;application/vnd.ecowin.chart|maker;application/vnd.framemaker|man;application/x-troff-man|man;text/troff|mb;application/mathematica|mbk;application/vnd.mobius.mbk|mbox;application/mbox|mc1;application/vnd.medcalcdata|mcd;application/vnd.mcd|mcurl;text/vnd.curl.mcurl|mdb;application/x-msaccess|mdi;image/vnd.ms-modi|me;application/x-troff-me|me;text/troff|mfm;application/vnd.mfmp|mgz;application/vnd.proteus.magazine|mht;message/rfc822|mhtml;message/rfc822|mime;message/rfc822|mj2;video/mj2|mjp2;video/mj2|mlp;application/vnd.dolby.mlp|mmd;application/vnd.chipnuts.karaoke-mmd|mmf;application/vnd.smaf|mmr;image/vnd.fujixerox.edmics-mmr|mny;application/x-msmoney|mobi;application/x-mobipocket-ebook|mp2a;audio/mpeg|mp4a;audio/mp4|mp4s;application/mp4|mp4v;video/mp4|mpa;video/mpeg|mpc;application/vnd.mophun.certificate|mpg4;video/mp4|mpkg;application/vnd.apple.installer+xml|mpm;application/vnd.blueice.multipass|mpn;application/vnd.mophun.application|mpp;application/vnd.ms-project|mpt;application/vnd.ms-project|mpy;application/vnd.ibm.minipay|mqy;application/vnd.mobius.mqy|mrc;application/marc|ms;application/x-troff-ms|mscml;application/mediaservercontrol+xml|mseed;application/vnd.fdsn.mseed|mseq;application/vnd.mseq|msf;application/vnd.epson.msf|msi;application/x-msdownload|msl;application/vnd.mobius.msl|ms;text/troff|msty;application/vnd.muvee.style|mts;model/vnd.mts|mus;application/vnd.musician|musicxml;application/vnd.recordare.musicxml+xml|mvb;application/x-msmediaview|mwf;application/vnd.mfer|mxf;application/mxf|mxl;application/vnd.recordare.musicxml|mxml;application/xv+xml|mxs;application/vnd.triscape.mxs|nb;application/mathematica|ncx;application/x-dtbncx+xml|n-gage;application/vnd.nokia.n-gage.symbian.install|ngdat;application/vnd.nokia.n-gage.data|" $sIANA_NonStrict &= "nlu;application/vnd.neurolanguage.nlu|nml;application/vnd.enliven|nnd;application/vnd.noblenet-directory|nns;application/vnd.noblenet-sealer|nnw;application/vnd.noblenet-web|npx;image/vnd.net-fpx|nsf;application/vnd.lotus-notes|nws;message/rfc822|oa2;application/vnd.fujitsu.oasys2|oa3;application/vnd.fujitsu.oasys3|o;application/octet-stream|oas;application/vnd.fujitsu.oasys|obd;application/x-msbinder|obj;application/octet-stream|odb;application/vnd.oasis.opendocument.database|odc;application/vnd.oasis.opendocument.chart|odf;application/vnd.oasis.opendocument.formula|odft;application/vnd.oasis.opendocument.formula-template|odg;application/vnd.oasis.opendocument.graphics|odi;application/vnd.oasis.opendocument.image|odp;application/vnd.oasis.opendocument.presentation|ods;application/vnd.oasis.opendocument.spreadsheet|odt;application/vnd.oasis.opendocument.text|oga;audio/ogg|ogv;video/ogg|ogx;application/ogg|onepkg;application/onenote|onetmp;application/onenote|opf;application/oebps-package+xml|oprc;application/vnd.palm|org;application/vnd.lotus-organizer|osf;application/vnd.yamaha.openscoreformat|osfpvg;application/vnd.yamaha.openscoreformat.osfpvg+xml|otc;application/vnd.oasis.opendocument.chart-template|otf;application/x-font-otf|otg;application/vnd.oasis.opendocument.graphics-template|oth;application/vnd.oasis.opendocument.text-web|oti;application/vnd.oasis.opendocument.image-template|otm;application/vnd.oasis.opendocument.text-master|otp;application/vnd.oasis.opendocument.presentation-template|ots;application/vnd.oasis.opendocument.spreadsheet-template|ott;application/vnd.oasis.opendocument.text-template|oxt;application/vnd.openofficeorg.extension|p10;application/pkcs10|p12;application/x-pkcs12|p7b;application/x-pkcs7-certificates|p7c;application/pkcs7-mime|p7m;application/pkcs7-mime|p7r;application/x-pkcs7-certreqresp|p7s;application/pkcs7-signature|pas;text/x-pascal|pbd;application/vnd.powerbuilder6|pcf;application/x-font-pcf|pcl;application/vnd.hp-pcl|pclxl;application/vnd.hp-pclxl|" $sIANA_NonStrict &= "pcurl;application/vnd.curl.pcurl|pcx;image/x-pcx|pdb;application/vnd.palm|pdb;chemical/x-pdb|pfa;application/x-font-type1|pfb;application/x-font-type1|pfm;application/x-font-type1|pfr;application/font-tdpfr|pfx;application/x-pkcs12|pgp;application/pgp-encrypted|php;text/x-php|pict;image/pict|pkg;application/octet-stream|pki;application/pkixcmp|pkipath;application/pkix-pkipath|plb;application/vnd.3gpp.pic-bw-large|plc;application/vnd.mobius.plc|plf;application/vnd.pocketlearn|pls;application/pls+xml|pl;text/plain|pml;application/vnd.ctc-posml|pntg;image/x-macpaint|pnt;image/x-macpaint|portpkg;application/vnd.macports.portpkg|pot;application/vnd.ms-powerpoint|potm;application/vnd.ms-powerpoint.template.macroenabled.12|potx;application/vnd.openxmlformats-officedocument.presentationml.template|ppa;application/vnd.ms-powerpoint|ppam;application/vnd.ms-powerpoint.addin.macroenabled.12|ppd;application/vnd.cups-ppd|pps;application/vnd.ms-powerpoint|ppsm;application/vnd.ms-powerpoint.slideshow.macroenabled.12|ppsx;application/vnd.openxmlformats-officedocument.presentationml.slideshow|pptm;application/vnd.ms-powerpoint.presentation.macroenabled.12|pptx;application/vnd.openxmlformats-officedocument.presentationml.presentation|pqa;application/vnd.palm|prc;application/x-mobipocket-ebook|pre;application/vnd.lotus-freelance|prf;application/pics-rules|psb;application/vnd.3gpp.pic-bw-small|psd;image/vnd.adobe.photoshop|psf;application/x-font-linux-psf|p;text/x-pascal|ptid;application/vnd.pvi.ptid1|pub;application/x-mspublisher|pvb;application/vnd.3gpp.pic-bw-var|pwn;application/vnd.3m.post-it-notes|pwz;application/vnd.ms-powerpoint|pya;audio/vnd.ms-playready.media.pya|pyc;application/x-python-code|pyo;application/x-python-code|py;text/x-python|pyv;video/vnd.ms-playready.media.pyv|qam;application/vnd.epson.quickanime|qbo;application/vnd.intu.qbo|qfx;application/vnd.intu.qfx|qps;application/vnd.publishare-delta-tree|qtif;image/x-quicktime|qti;image/x-quicktime|qwd;application/vnd.quark.quarkxpress|qwt;application/vnd.quark.quarkxpress|" $sIANA_NonStrict &= "qxb;application/vnd.quark.quarkxpress|qxd;application/vnd.quark.quarkxpress|qxl;application/vnd.quark.quarkxpress|qxt;application/vnd.quark.quarkxpress|rar;application/x-rar-compressed|rcprofile;application/vnd.ipunplugged.rcprofile|rdz;application/vnd.data-vision.rdz|rep;application/vnd.businessobjects|res;application/x-dtbresource+xml|rif;application/reginfo+xml|rl;application/resource-lists+xml|rlc;image/vnd.fujixerox.edmics-rlc|rld;application/resource-lists-diff+xml|rmi;audio/midi|rmp;audio/x-pn-realaudio-plugin|rms;application/vnd.jcp.javame.midlet-rms|rnc;application/relax-ng-compact-syntax|rpm;application/x-rpm|rpss;application/vnd.nokia.radio-presets|rpst;application/vnd.nokia.radio-preset|rq;application/sparql-query|rs;application/rls-services+xml|rsd;application/rsd+xml|rss;application/rss+xml|rtf;application/rtf|rtf;text/rtf|saf;application/vnd.yamaha.smaf-audio|sbml;application/sbml+xml|sc;application/vnd.ibm.secure-container|scd;application/x-msschedule|scm;application/vnd.lotus-screencam|scq;application/scvp-cv-request|scs;application/scvp-cv-response|scurl;text/vnd.curl.scurl|sda;application/vnd.stardivision.draw|sdc;application/vnd.stardivision.calc|sdd;application/vnd.stardivision.impress|sdkd;application/vnd.solent.sdkm+xml|sdkm;application/vnd.solent.sdkm+xml|sdp;application/sdp|sdw;application/vnd.stardivision.writer|see;application/vnd.seemail|seed;application/vnd.fdsn.seed|sema;application/vnd.sema|semd;application/vnd.semd|semf;application/vnd.semf|ser;application/java-serialized-object|setpay;application/set-payment-initiation|setreg;application/set-registration-initiation|sfd-hdstx;application/vnd.hydrostatix.sof-data|sfs;application/vnd.spotfire.sfs|sgl;application/vnd.stardivision.writer-global|shf;application/shf+xml|sic;application/vnd.wap.sic|sig;application/pgp-signature|sis;application/vnd.symbian.install|sisx;application/vnd.symbian.install|si;text/vnd.wap.si|sitx;application/x-stuffitx|slc;application/vnd.wap.slc|sldm;application/vnd.ms-powerpoint.slide.macroenabled.12|" $sIANA_NonStrict &= "sldx;application/vnd.openxmlformats-officedocument.presentationml.slide|slt;application/vnd.epson.salt|sl;text/vnd.wap.sl|smf;application/vnd.stardivision.math|snf;application/x-font-snf|spc;application/x-pkcs7-certificates|spf;application/vnd.yamaha.smaf-phrase|spot;text/vnd.in3d.spot|spp;application/scvp-vp-response|spq;application/scvp-vp-request|spx;audio/ogg|srx;application/sparql-results+xml|sse;application/vnd.kodak-descriptor|ssf;application/vnd.epson.ssf|ssml;application/ssml+xml|stc;application/vnd.sun.xml.calc.template|std;application/vnd.sun.xml.draw.template|s;text/x-asm|stf;application/vnd.wt.stf|sti;application/vnd.sun.xml.impress.template|stk;application/hyperstudio|stl;application/vnd.ms-pki.stl|str;application/vnd.pg.format|stw;application/vnd.sun.xml.writer.template|sus;application/vnd.sus-calendar|susp;application/vnd.sus-calendar|svd;application/vnd.svd|svgz;image/svg+xml|swa;application/x-director|swi;application/vnd.arastra.swi|sxc;application/vnd.sun.xml.calc|sxd;application/vnd.sun.xml.draw|sxg;application/vnd.sun.xml.writer.global|sxi;application/vnd.sun.xml.impress|sxm;application/vnd.sun.xml.math|sxw;application/vnd.sun.xml.writer|tao;application/vnd.tao.intent-module-archive|t;application/x-troff|tcap;application/vnd.3gpp2.tcap|teacher;application/vnd.smart.teacher|text;text/plain|tfm;application/x-tex-tfm|tgz;application/x-gzip|tmo;application/vnd.tmobile-livetv|torrent;application/x-bittorrent|tpl;application/vnd.groove-tool-template|tpt;application/vnd.trid.tpt|tra;application/vnd.trueapp|tr;application/x-troff|trm;application/x-msterminal|tr;text/troff|ttc;application/x-font-ttf|t;text/troff|ttf;application/x-font-ttf|twd;application/vnd.simtech-mindmapper|twds;application/vnd.simtech-mindmapper|txd;application/vnd.genomatix.tuxedo|txf;application/vnd.mobius.txf|u32;application/x-authorware-bin|udeb;application/x-debian-package|ufd;application/vnd.ufdl|ufdl;application/vnd.ufdl|umj;application/vnd.umajin|unityweb;application/vnd.unity|uoml;application/vnd.uoml+xml|" $sIANA_NonStrict &= "uris;text/uri-list|uri;text/uri-list|urls;text/uri-list|utz;application/vnd.uiq.theme|uu;text/x-uuencode|vcf;text/x-vcard|vcg;application/vnd.groove-vcard|vcs;text/x-vcalendar|vcx;application/vnd.vcx|vis;application/vnd.visionary|viv;video/vnd.vivo|vor;application/vnd.stardivision.writer|vox;application/x-authorware-bin|vsd;application/vnd.visio|vsf;application/vnd.vsf|vss;application/vnd.visio|vst;application/vnd.visio|vsw;application/vnd.visio|vtu;model/vnd.vtu|w3d;application/x-director|wad;application/x-doom|wax;audio/x-ms-wax|wbmxl;application/vnd.wap.wbxml|wbs;application/vnd.criticaltools.wbs+xml|wbxml;application/vnd.wap.wbxml|wcm;application/vnd.ms-works|wdb;application/vnd.ms-works|wiz;application/msword|wks;application/vnd.ms-works|wma;audio/x-ms-wma|wmd;application/x-ms-wmd|wmf;application/x-msmetafile|wm;video/x-ms-wm|wmv;video/x-ms-wmv|wmx;video/x-ms-wmx|wmz;application/x-ms-wmz|wpd;application/vnd.wordperfect|wpl;application/vnd.ms-wpl|wps;application/vnd.ms-works|wqd;application/vnd.wqd|wri;application/x-mswrite|wsdl;application/wsdl+xml|wspolicy;application/wspolicy+xml|wtb;application/vnd.webturbo|wvx;video/x-ms-wvx|x32;application/x-authorware-bin|x3d;application/vnd.hzn-3d-crossword|xap;application/x-silverlight-app|xar;application/vnd.xara|xbap;application/x-ms-xbap|xbd;application/vnd.fujixerox.docuworks.binder|xdm;application/vnd.syncml.dm+xml|xdp;application/vnd.adobe.xdp+xml|xdw;application/vnd.fujixerox.docuworks|xenc;application/xenc+xml|xer;application/patch-ops-error+xml|xfdf;application/vnd.adobe.xfdf|xfdl;application/vnd.xfdl|xhvml;application/xv+xml|xif;image/vnd.xiff|xla;application/vnd.ms-excel|xlam;application/vnd.ms-excel.addin.macroenabled.12|xlb;application/vnd.ms-excel|xlc;application/vnd.ms-excel|xlm;application/vnd.ms-excel|xlsb;application/vnd.ms-excel.sheet.binary.macroenabled.12|xlsm;application/vnd.ms-excel.sheet.macroenabled.12|xlsx;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|xlt;application/vnd.ms-excel|" $sIANA_NonStrict &= "xltm;application/vnd.ms-excel.template.macroenabled.12|xltx;application/vnd.openxmlformats-officedocument.spreadsheetml.template|xlw;application/vnd.ms-excel|xo;application/vnd.olpc-sugar|xop;application/xop+xml|xpdl;application/xml|xpi;application/x-xpinstall|xpr;application/vnd.is-xpr|xps;application/vnd.ms-xpsdocument|xpw;application/vnd.intercon.formnet|xpx;application/vnd.intercon.formnet|xsm;application/vnd.syncml+xml|xspf;application/xspf+xml|xvm;application/xv+xml|xvml;application/xv+xml|zaz;application/vnd.zzazz.deck+xml|zir;application/vnd.zul|zirz;application/vnd.zul|zmm;application/vnd.handheld-entertainment+xml|" EndIf Return $sIANA_Strict & ($iIANA_NonStrict ? $sIANA_NonStrict : "") EndFunc ;==>__FileGetMimeType_GetDB Incomaptible with pre 3.3.10 versions of AutoIt Other methods/UDFs: >urlmon.dll, >_WinHttp UDF (__WinHttpMIMEType)1 point
-
_FileGetMimeType UDF
DatMCEyeBall reacted to KaFu for a topic
Now, that seems to be some code I'll have to add to the next release of SMF too ...1 point -
Date.au3
jaberwacky reacted to trancexx for a topic
It's not that it's not. You could do it like this: #include <WinAPILocale.au3> #include <StructureConstants.au3> #include <Date.au3> ConsoleWrite("Default:" & @CRLF) For $i = 1 To 7 ConsoleWrite(@TAB & __DateDayOfWeek($i) & @CRLF) Next ConsoleWrite("--------------------------------" & @CRLF) ConsoleWrite(@CRLF & "0 (LONG_NAME | ENG):" & @CRLF) For $i = 1 To 7 ConsoleWrite(@TAB & __DateDayOfWeek($i, 0) & @CRLF) Next ConsoleWrite(@CRLF & "1 (SHORT_NAME | ENG):" & @CRLF) For $i = 1 To 7 ConsoleWrite(@TAB & __DateDayOfWeek($i, 1) & @CRLF) Next ConsoleWrite(@CRLF & "2 (LONG_NAME | LOCALE_USER):" & @CRLF) For $i = 1 To 7 ConsoleWrite(@TAB & __DateDayOfWeek($i, 2) & @CRLF) Next ConsoleWrite(@CRLF & "3 (SHORT_NAME | LOCALE_USER):" & @CRLF) For $i = 1 To 7 ConsoleWrite(@TAB & __DateDayOfWeek($i, 3) & @CRLF) Next Func __DateDayOfWeek($iDayNum, $iFormat = Default) Local Enum $LONG_NAME = 0, $SHORT_NAME = 1, $LOCALE_USER = 2, $MONDAY_IS_NO1 = 128 If $iFormat = Default Then $iFormat = 0 $iDayNum = Int($iDayNum) If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "") Local $SYSTEMTIME = DllStructCreate($tagSYSTEMTIME) $SYSTEMTIME.Year = BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006 $SYSTEMTIME.Month = 1 $SYSTEMTIME.DayOfWeek = $iDayNum $SYSTEMTIME.Day = $iDayNum Return _WinAPI_GetDateFormat(BitAND($iFormat, $LOCALE_USER) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $SYSTEMTIME, 0, BitAND($iFormat, $SHORT_NAME) ? "ddd" : "dddd") EndFunc1 point -
GetDateFormatEx
jaberwacky reacted to LarsJ for a topic
Try this: GetDateFormatEx() Func GetDateFormatEx() Local $aRet = DllCall("Kernel32.dll", "int", "GetDateFormatEx", "wstr", "en-US", _ ; "da-DK", "de-DE", "en-US", "sv-SE", http://www.lingoes.net/en/translator/langcode.htm "dword", 2, _ ; 2 = DATE_LONGDATE "struct*", 0, _ "ptr", 0, _ ; Note that the parameters 2 and 4 depend on each other "wstr", "", _ "int", 2048, _ "ptr", 0) ConsoleWrite("@error: " & @error & @CRLF & _ "$aRet[0]: " & $aRet[0] & @CRLF & _ "$aRet[5]: " & $aRet[5] & @CRLF & @CRLF) EndFunc1 point -
Noob VB question inside...
jaberwacky reacted to Richard Robertson for a topic
VB.Net doesn't work even remotely like C++. Including a header file isn't valid in VB.Net. It's also worth noting that LOCALE_NAME_MAX_LENGTH isn't a variable. It's a preprocessor directive and is treated as the literal value it represents. You need to actually write a C/C++ application to use it in a program, or search the headers for the directive manually.1 point -
Servant, Yes. Did you try searching the forum (the search box is at top right)? This has been answered many times - and often by me). An example of one way to do it: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Local $iCount = 0 $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 400, 100, BitOR($WS_VSCROLL, $WS_BORDER)) $cButton = GUICtrlCreateButton("Add", 10, 200, 80, 30) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $iCount += 1 ; Get current top index $iIndex = _GUICtrlListBox_GetTopIndex($cList) ; Add a line GUICtrlSetData($cList, "Line " & $iCount) ; Set new top index _GUICtrlListBox_SetTopIndex($cList, $iIndex + 1) EndSwitch WEnd all clear? M231 point
-
GetDateFormatEx
jaberwacky reacted to guinness for a topic
#include <WinAPILocale.au3> ConsoleWrite(_WinAPI_GetDateFormat($LOCALE_USER_DEFAULT, 0, 0, 'dddd') & @CRLF) The only difference I can see is the function call.1 point -
_FileGetMimeType UDF
DatMCEyeBall reacted to guinness for a topic
Then we wouldn't be having this conversation.1 point -
Servant, Personally I would use a List control for something like this, but an Edit control could also serve. Look at GUICtrlCreateList for more details on List controls. M231 point
-
I created this after I developed and because I wanted to add an entry to the contextmenu when selecting any file or folder. The entry will pass the file/folder name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the file/folder that was selected. Any problems or suggestions then please post below. Thanks. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _ShellAll ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting a file and folder, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= ; None ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; _ShellAll_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; _ShellAll_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __ShellAll_RegistryGet ......; Retrieve an array of registry entries for a specific key. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellAll_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; Syntax ........: _ShellAll_Install($sText[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ; $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ; $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sIconPath - [optional] Location of the icon e.g. program executable or dll file. Default is @ScriptFullPath. ; $iIcon - [optional] Index of icon to be used. Default is 0. ; $fAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $fExtended - [optional] Show in the Extended contextmenu using Shift + Right click. Default is False. ; Return values .: Success - RegWrite() Return code. ; Failure - none ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellAll_Install($sText, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $fAllUsers = False, $fExtended = False) Local $aArray[3] = [2, '*', 'Directory'], $i64Bit = '' If $iIcon = Default Then $iIcon = 0 EndIf If $sFilePath = Default Then $sFilePath = @ScriptFullPath EndIf If $sIconPath = Default Then $sIconPath = @ScriptFullPath EndIf If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf For $i = 1 To $aArray[0] If $fAllUsers Then $aArray[$i] = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell' Else $aArray[$i] = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell' EndIf Next $sName = StringRegExpReplace($sName, '.[^./]*$', '') If StringStripWS($sName, 8) = '' Or FileExists($sFilePath) = 0 Then Return SetError(1, 0, 0) EndIf _ShellAll_Uninstall($sName, $fAllUsers) For $i = 1 To $aArray[0] RegWrite($aArray[$i] & $sName, '', 'REG_SZ', $sText) RegWrite($aArray[$i] & $sName, 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) RegWrite($aArray[$i] & $sName & 'command', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') If $fExtended Then RegWrite($aArray[$i], 'Extended', 'REG_SZ', '') EndIf Next Return SetError(@error, 0, @error) EndFunc ;==>_ShellAll_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellAll_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellAll_Uninstall([$sName = @ScriptName[, $fAllUsers = False]]) ; Parameters ....: $sName - [optional] Name of the Program. Default is @ScriptName. ; $fAllUsers - [optional] Was it added to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - Returns 2D Array of registry entries. ; Failure - Returns 0 and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellAll_Uninstall($sName = @ScriptName, $fAllUsers = False) Local $aArray[3] = [2, '*', 'Directory'], $i64Bit = '' If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf For $i = 1 To $aArray[0] If $fAllUsers Then $aArray[$i] = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell' Else $aArray[$i] = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell' EndIf Next $sName = StringRegExpReplace($sName, '.[^./]*$', '') If StringStripWS($sName, 8) = '' Then Return SetError(1, 0, 0) EndIf Local $aFinal[1][5] = [[0, 5]], $aReturn = 0, $sDelete = '' For $i = 1 To $aArray[0] $aReturn = __ShellAll_RegistryGet($aArray[$i]) If $aReturn[0][0] > 0 Then For $j = 1 To $aReturn[0][0] If $aReturn[$j][0] = $sName And $sDelete <> $aReturn[$j][1] Then $sDelete = $aReturn[$j][1] RegDelete($sDelete) EndIf Next ReDim $aFinal[$aFinal[0][0] + $aReturn[0][0] + 1][$aReturn[0][1]] For $j = 1 To $aReturn[0][0] $aFinal[0][0] += 1 For $k = 0 To $aReturn[0][1] - 1 $aFinal[$aFinal[0][0]][$k] = $aReturn[$j][$k] Next Next $aFinal[0][1] = $aReturn[0][1] EndIf Next Return $aFinal EndFunc ;==>_ShellAll_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __ShellAll_RegistryGet($sRegistryKey) Local $aArray[1][5] = [[0, 5]], $iCount_1 = 0, $iCount_2 = 0, $iDimension = 0, $iError = 0, $sRegistryKey_All = '', $sRegistryKey_Main = '', $sRegistryKey_Name = '', _ $sRegistryKey_Value = '' While 1 If $iError Then ExitLoop EndIf $sRegistryKey_Main = RegEnumKey($sRegistryKey, $iCount_1 + 1) If @error Then $sRegistryKey_All = $sRegistryKey $iError = 1 Else $sRegistryKey_All = $sRegistryKey & $sRegistryKey_Main EndIf $iCount_2 = 0 While 1 $sRegistryKey_Name = RegEnumVal($sRegistryKey_All, $iCount_2 + 1) If @error Then ExitLoop EndIf If ($aArray[0][0] + 1) >= $iDimension Then $iDimension = ($aArray[0][0] + 1) * 2 ReDim $aArray[$iDimension][$aArray[0][1]] EndIf $sRegistryKey_Value = RegRead($sRegistryKey_All, $sRegistryKey_Name) $aArray[$aArray[0][0] + 1][0] = $sRegistryKey_Main $aArray[$aArray[0][0] + 1][1] = $sRegistryKey_All $aArray[$aArray[0][0] + 1][2] = $sRegistryKey & $sRegistryKey_Main & '' & $sRegistryKey_Name $aArray[$aArray[0][0] + 1][3] = $sRegistryKey_Name $aArray[$aArray[0][0] + 1][4] = $sRegistryKey_Value $aArray[0][0] += 1 $iCount_2 += 1 WEnd $iCount_1 += 1 WEnd ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]] Return $aArray EndFunc ;==>__ShellAll_RegistryGetExample 1: #include '_ShellAll.au3' Example() Func Example() _ShellAll_Install('Start ShellAll') ; Add the running EXE to the Shell ContextMenu. This will only display when selecting a file and folder. Sleep(10000) _ShellAll_Uninstall() ; Remove the running EXE from the Shell ContextMenu. EndFunc ;==>ExampleAll of the above has been included in a ZIP file. ShellAll.zip Extended: A example.1 point