@MountainMan:
I'll try but it looks like a nightmare. midl.exe is complaining about errors in oaidl.idl, which isn't part of the project, which couldn't be found until I copied it into my source folder despite running vcvarsall.bat, and comes straight from the SDK so why on earth would it have errors anyway?
I got the paths problems fixed but the big issue now is the MIDL2003 redefinition problem. It gives that error whenever you define something that's already defined in Windows. Which is everything. If anyone has dealt with this before, let me know.Code:C:\vb6\tl_ole\source>C:\PROGRA~2\MIA713~1\\Windows\v7.0A\Bin\midl.exe /nologo /e nv win64 /nocpp /tlb "olelib64.odl" olelib.odl 64 bit Processing .\olelib.odl 64 bit Processing .\oaidl.idl oaidl.idl(26) : error MIDL2025 : syntax error : expecting an interface name or D ispatchInterfaceName or CoclassName or ModuleName or LibraryName or ContractName or a type specification near "ifndef" oaidl.idl(27) : error MIDL2026 : cannot recover from earlier syntax errors; abor ting compilation
Edit: What changes to the code itself would need to be made (what is the problem encountered when trying to use it in 64bit Office), assuming I can overcome the redefinition issue which might not be possible as every solution I've encountered says it's by design and to rename things.
Edit: So I installed 64-bit office, and definitely need more info about what part of the typlibs won't work. Note that olelib includes API calls, but I've had problems with these everywhere and strongly suggest always using your own declares in a module.
This is what I tried, and it worked fine with the current versions. Note that IShellItem.GetDisplayname returns a pointer, but VBA doesn't know that thus the LongPtr type isn't needed. If you needed it down the road, there apparently is a CLngPtr() function built in.
Code:Private Sub CommandButton1_Click() Dim pidl As Long Dim sp As String Dim psi As IShellItem Dim sb As String Dim pstr As Long sp = "C:\temp\tracks.jpg" pidl = ILCreateFromPathW(StrPtr(sp)) 'Both of these methods work 'Call SHCreateShellItem(0&, 0&, pidl, psi) Call SHCreateItemFromIDList(pidl, IID_IShellItem, psi) psi.GetDisplayName SIGDN_FILESYSPATH, pstr MsgBox BStrFromLPWStr(pstr) Call ILFree(pidl) End Sub 'module Public Declare PtrSafe Function SHCreateShellItem Lib "shell32" (ByVal pidlParent As Long, ByVal psfParent As Long, ByVal pidl As Long, ppsi As IShellItem) As Long Public Declare PtrSafe Function SHCreateItemFromIDList Lib "shell32" (ByVal pidl As Long, riid As UUID, ppv As Any) As Long Public Declare PtrSafe Function SHCreateShellItemArrayFromIDLists Lib "shell32" (ByVal cidl As Long, ByVal rgpidl As Long, ppsiItemArray As IShellItemArray) As Long Public Declare PtrSafe Function ILCreateFromPathW Lib "shell32" (ByVal pwszPath As LongPtr) As Long Public Declare PtrSafe Sub ILFree Lib "shell32" (ByVal pidl As Long) Public Declare PtrSafe Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As LongPtr, Optional ByVal pszStrPtr As Long) As Long Public Declare PtrSafe Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long) Public Function BStrFromLPWStr(lpWStr As Long, Optional ByVal CleanupLPWStr As Boolean = True) As String SysReAllocString VarPtr(BStrFromLPWStr), lpWStr If CleanupLPWStr Then CoTaskMemFree lpWStr End Function Public Function IID_IShellItem() As UUID Static IID As UUID If (IID.Data1 = 0) Then Call DEFINE_UUID(IID, &H43826D1E, CInt(&HE718), CInt(&H42EE), &HBC, &H55, &HA1, &HE2, &H61, &HC3, &H7B, &HFE) IID_IShellItem = IID End Function Public Sub DEFINE_UUID(Name As UUID, l As Long, w1 As Integer, w2 As Integer, B0 As Byte, b1 As Byte, b2 As Byte, B3 As Byte, b4 As Byte, b5 As Byte, b6 As Byte, b7 As Byte) With Name .Data1 = l .Data2 = w1 .Data3 = w2 .Data4(0) = B0 .Data4(1) = b1 .Data4(2) = b2 .Data4(3) = B3 .Data4(4) = b4 .Data4(5) = b5 .Data4(6) = b6 .Data4(7) = b7 End With End Sub




Reply With Quote