I'm trying to track down a GUID Microsoft has hidden for seemingly no other reason than to make it impossible to use certain interfaces in VB.
Microsoft provides this sample of how to get a pointer to it:
Code:
// Retrieve the IID_ITextServices interface identifier from Msftedit.dll.
IID* pIID_ITS = (IID*)(VOID*)GetProcAddress(hmodRichEdit, "IID_ITextServices");
// Retrieve the ITextServices interface.
hr = pUnk->QueryInterface(*pIID_ITS, (void**)&pTextServices);
Code:
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, ByVal lpProcName As LongPtr) As LongPtr
Private Declare Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As LongPtr) As LongPtr
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long
Private Sub Command1_Click()
Dim hRichEd As LongPtr
hRichEd = LoadLibraryW(StrPtr("msftedit.dll"))
If hRichEd Then
Dim lpProc As LongPtr
lpProc = GetProcAddress(hRichEd, StrPtr("IID_ITextServices"))
If lpProc Then
Dim tIID As UUID
CopyMemory tIID, ByVal lpProc, LenB(tIID)
Text1.Text = "IID_ITextServices=" & GUIDToString(tIID)
Else
Debug.Print "no lpProc; hRichEdit=" & hRichEd
End If
FreeLibrary hRichEd
Else
Debug.Print "no hRichEd"
End If
End Sub
Public Function GUIDToString(tg As UUID, Optional bBrack As Boolean = True) As String
'StringFromGUID2 never works, even "working" code from vbaccelerator AND MSDN
GUIDToString = Right$("00000000" & Hex$(tg.Data1), 8) & "-" & Right$("0000" & Hex$(tg.Data2), 4) & "-" & Right$("0000" & Hex$(tg.Data3), 4) & _
"-" & Right$("00" & Hex$(CLng(tg.Data4(0))), 2) & Right$("00" & Hex$(CLng(tg.Data4(1))), 2) & "-" & Right$("00" & Hex$(CLng(tg.Data4(2))), 2) & _
Right$("00" & Hex$(CLng(tg.Data4(3))), 2) & Right$("00" & Hex$(CLng(tg.Data4(4))), 2) & Right$("00" & Hex$(CLng(tg.Data4(5))), 2) & _
Right$("00" & Hex$(CLng(tg.Data4(6))), 2) & Right$("00" & Hex$(CLng(tg.Data4(7))), 2)
If bBrack Then GUIDToString = "{" & GUIDToString & "}"
End Function
I've checked and msftedit.dll does have IID_ITextServices listed in the function export table, but GetProcAddress is not finding it (lpProc = 0). Any ideas what I'm doing wrong? MS' sample code doesn't explain how it obtained hmodRichEdit, so I thought I'd use the fairly typical way of LoadLibrary.
(Yes I know this particular GUID can be found online, but other ones in this DLL can't, and I'm using this for verification of method).