$TYPECHECK ON
$IFNDEF __OLE_INC
$DEFINE __OLE_INC
$DEFINE EC_COMPLETE &h1
$DEFINE CLSCTX_INPROC_SERVER 1&
$DEFINE CLSCTX_INPROC_HANDLER 2&
$DEFINE CLSCTX_LOCAL_SERVER 4&
$DEFINE CLSCTX_REMOTE_SERVER 16&
$DEFINE CLSCTX_NO_CODE_DOWNLOAD 400&
$DEFINE CLSCTX_NO_FAILURE_LOG 4000&
CONST CLSCTX_SERVER AS LONG = CLSCTX_INPROC_SERVER OR CLSCTX_LOCAL_SERVER OR CLSCTX_REMOTE_SERVER
CONST CLSCTX_ALL AS LONG = CLSCTX_INPROC_HANDLER OR CLSCTX_SERVER
CONST CLSCTX_INPROC AS LONG = CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER
$DEFINE S_OK 0&
TYPE GUID
Data1 AS LONG
Data2 AS WORD
Data3 AS WORD
Data4 AS STRING * 8
END TYPE
FUNCTION GUID$(ClassID AS STRING) AS STRING
DIM i AS INTEGER
DIM DATA(8) AS WORD
DIM RtnStr AS STRING: RtnStr = SPACE$(16)
ClassID = UCASE$(ClassID)
IF INSTR(ClassID," ") THEN ClassID = REPLACESUBSTR$(ClassID," ","")
IF INSTR(ClassID,"{") THEN ClassID = REPLACESUBSTR$(ClassID,"{","")
IF INSTR(ClassID,"{") THEN ClassID = REPLACESUBSTR$(ClassID,"}","")
IF INSTR(ClassID,":") THEN ClassID = REPLACESUBSTR$(ClassID,":","")
IF INSTR(ClassID,"CLSID") THEN ClassID = REPLACESUBSTR$(ClassID,"CLSID","")
IF LEFT$(ClassID,1) = "{" THEN ClassID = MID$(ClassID, 2, LEN(ClassID)-1)
IF RIGHT$(ClassID,1) = "}" THEN ClassID = LEFT$(ClassID, LEN(ClassID)-1)
DATA(0) = VAL(CONVBASE$( MID$(ClassID, 5, 4), 16, 10))
DATA(1) = VAL(CONVBASE$( MID$(ClassID, 1, 4), 16, 10))
DATA(2) = VAL(CONVBASE$( MID$(ClassID, 10, 4), 16, 10))
DATA(3) = VAL(CONVBASE$( MID$(ClassID, 15, 4), 16, 10))
DATA(4) = VAL(CONVBASE$( MID$(ClassID, 22, 2) + MID$(ClassID, 20, 2), 16 , 10))
DATA(5) = VAL(CONVBASE$( MID$(ClassID, 27, 2) + MID$(ClassID, 25, 2), 16 , 10))
DATA(6) = VAL(CONVBASE$( MID$(ClassID, 31, 2) + MID$(ClassID, 29, 2), 16 , 10))
DATA(7) = VAL(CONVBASE$( MID$(ClassID, 35, 2) + MID$(ClassID, 33, 2), 16 , 10))
MEMCPY (VARPTR(RtnStr),VARPTR(DATA(0)), 16)
RESULT = RtnStr
END FUNCTION
DECLARE FUNCTION StringFromGUID2 LIB "ole32.dll" ALIAS "StringFromGUID2"(rclsid AS GUID, BYVAL lpsz AS LONG, BYVAL cbMax AS LONG) AS LONG
DECLARE FUNCTION CLSIDFromProgID LIB "ole32.dll" ALIAS "CLSIDFromProgID"(BYVAL lpszProgID AS LONG, pCLSID AS GUID) AS LONG
DECLARE FUNCTION CLSIDFromProgIDEx LIB "ole32.dll" ALIAS "CLSIDFromProgIDEx"(BYVAL lpszProgID AS LONG, pCLSID AS GUID) AS LONG
DECLARE FUNCTION ProgIDFromCLSID LIB "ole32.dll" ALIAS "ProgIDFromCLSID"(pCLSID AS GUID, lpszProgID AS LONG) AS LONG
DECLARE FUNCTION StringFromCLSID LIB "ole32.dll" ALIAS "StringFromCLSID"(pCLSID AS GUID, lpszProgID AS LONG) AS LONG
DECLARE FUNCTION IIDFromString LIB "ole32.dll" ALIAS "IIDFromString"(BYVAL lpsz AS STRING, ByRef lpiid AS GUID) AS LONG
DECLARE FUNCTION CoCreateGuid LIB "ole32.dll" ALIAS "CoCreateGuid" (lpGUID AS GUID) AS LONG
DECLARE SUB CoUninitialize LIB "ole32.dll" ALIAS "CoUninitialize" ()
DECLARE FUNCTION CoInitialize LIB "ole32.dll" ALIAS "CoInitialize" (BYVAL pvReserved AS LONG) AS LONG
DECLARE FUNCTION OleInitialize LIB "ole32.dll" ALIAS "OleInitialize" (pvReserved AS LONG) AS LONG
DECLARE SUB OleUninitialize LIB "ole32.dll" ALIAS "OleUninitialize"
DECLARE FUNCTION IsEqualGUID LIB "ole32.dll" ALIAS "IsEqualGUID"(rguid1 AS GUID, rguid2 AS GUID) AS LONG
DECLARE FUNCTION CoCreateInstance LIB "ole32" ALIAS "CoCreateInstance"( _
rclsid AS LONG, pUnkOuter AS LONG, _
dwClsContext AS LONG, riid AS LONG, _
ppv AS LONG) AS LONG
FUNCTION GuidStringFromGUID(rclsid AS GUID) AS STRING
DIM rc AS LONG
DIM stGuid AS STRING * 40
stGuid = STRING$(40, 0&)
rc = StringFromGUID2(rclsid, VARPTR(stGuid), (LEN(stGuid) - 1))
GuidStringFromGUID = LEFT$(stGuid, rc - 1)
END FUNCTION
$IFNDEF CALL_ASM_PROC_X
$DEFINE CALL_ASM_PROC_X
DECLARE FUNCTION CallAsmProc LIB "user32" ALIAS "CallWindowProcA" _
(Proc AS LONG, A1 AS LONG, A2 AS LONG, A3 AS LONG, A4 AS LONG) AS LONG
$ENDIF
DEFBYTE MCALLasmArray (0 TO 51) = _
{&H55,&H89,&HE5,&H8B,&H75,&H08,&H8B,&H06,&H89,&HC3,&HC1,&HE0,&H02,&H01,&HC6,&H81,_
&HFB,&H00,&H00,&H00,&H00,&H74,&H0B,&HFF,&H36,&H81,&HEE,&H04,&H00,&H00,&H00,&H4B,_
&H75,&HF5,&H8B,&H45,&H0C,&H8B,&H4D,&H10,&H50,&H8B,&H00,&HFF,&H14,&H08,&H89,&HEC,_
&H5D,&HC2,&H10,&H00}
DEFINT ptrMCALLasm = VARPTR (MCALLasmArray(0))
FUNCTIONI MCALL (...) AS LONG
DEFINT N
DIM Arg(0 TO (PARAMVALCOUNT - 2)) AS LONG
IF PARAMVALCOUNT > 1 THEN
Arg(0) = PARAMVALCOUNT - 2
IF PARAMVALCOUNT > 2 THEN
FOR N = 3 TO PARAMVALCOUNT
Arg(N - 2) = PARAMVAL(N)
NEXT N
END IF
Result = CallAsmProc (ptrMCALLasm, VARPTR(Arg(0)), PARAMVAL(1), PARAMVAL(2), 0)
END IF
END FUNCTIONI
$ENDIF
|
|