Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Last active August 29, 2015 14:21
Show Gist options
  • Save kumatti1/9494008c2380ca5387a3 to your computer and use it in GitHub Desktop.
Save kumatti1/9494008c2380ca5387a3 to your computer and use it in GitHub Desktop.
__vbaInStr
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Declare PtrSafe _
Function IIDFromString Lib "ole32.dll" ( _
ByVal lpsz As LongPtr, _
ByRef lpiid As GUID _
) As Long
Private Declare PtrSafe _
Function CoGetObject Lib "Ole32" ( _
ByVal pszName As LongPtr, _
ByVal pBindOptions As LongPtr, _
ByRef riid As GUID, _
ByRef ppv As Any) As Long
Private Declare PtrSafe _
Function vbaInStr Lib "msvbvm60.dll" Alias "#277" ( _
ByVal lcid As Long, _
ByVal s1 As LongPtr, _
ByVal s2 As LongPtr, _
ByVal arg1 As Long _
) As Long
Sub hoge()
Dim obj As Object '_Collection
Dim hr As Long
Dim iid As GUID
hr = IIDFromString(StrPtr("{A4C46780-499F-101B-BB78-00AA00383CBB}"), iid)
Debug.Print Hex$(hr)
'Collection
hr = CoGetObject(StrPtr("new:A4C4671C-499F-101B-BB78-00AA00383CBB"), 0, iid, obj)
Debug.Print Hex$(hr), obj Is Nothing
Const s = "あいうえお"
Dim ret As Long
ret = vbaInStr(&H411, StrPtr(s), StrPtr("え"), 1)
Debug.Print Hex$(ret)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment