Hallo Leute,
ich habe mein MS Office 2019 Prof. auf 64bit umgestellt.
Nun habe ich aber ein Problem, mit dem Aufruf einer DLL-Funktion.
Und zwar stürzt mein Programm bei folgender Zeile ab in der Funktion GetSpecialFolder
=>
Hat einer eine Idee was hier noch zusätzlich geändert werden muss.
Ich vermute es liegt an der Deklaration von
Ich hoffe jemand kann mir hier helfen.
Vielen Dank im Voraus.
Gruß Achilleus
Hallo Leute,
einfach die Suchanfrage in Google umgestellt und schon habe ich die Lösung:
VBA - Office 365 x64 Bit - Vollständiger Absturz - Stack Overflow
Gruß Achilleus
Beiträge zusammengefügt. ~Thunderbolt
ich habe mein MS Office 2019 Prof. auf 64bit umgestellt.
Nun habe ich aber ein Problem, mit dem Aufruf einer DLL-Funktion.
VB.NET-Quellcode
- ' Ordner-Auflistung
- Public Enum SpecialFolderIDs
- sfidDESKTOP = &H0 ' Desktop
- sfidINTERNET = &H1 ' Internet Explorer (icon on desktop)
- sfidPROGRAMS = &H2 ' Start Menu\Programs
- sfidCONTROLS = &H3 ' My Computer\Control Panel
- sfidPRINTERS = &H4 ' My Computer\Printers
- sfidPERSONAL = &H5 ' My Documents
- sfidFAVORITES = &H6 ' \Favorites
- sfidSTARTUP = &H7 ' StartMenu\Programs\Startup
- sfidRECENT = &H8 ' \Recent
- sfidSENDTO = &H9 ' \SendTo
- sfidBITBUCKET = &HA ' \Recycle Bin
- sfidSTARTMENU = &HB ' \StartMenu
- sfidDESKTOPDIRECTORY = &H10 ' name>\Desktop
- sfidDRIVERS = &H11 ' My Computer
- sfidNETWORK = &H12 ' Network Neighborhood
- sfidNETHOOD = &H13 ' \nethood
- sfidFONTS = &H14 ' windows\fonts
- sfidTEMPLATES = &H15 ' Vorlagen
- sfidCOMMON_STARTMENU = &H16 ' All Users\StartMenu
- sfidCOMMON_PROGRAMS = &H17 ' AllUsers\Programs
- sfidCOMMON_STARTUP = &H18 ' AllUsers\Startup
- sfidCOMMON_DESKTOPDIRECTORY = &H19 ' AllUsers\Desktop
- sfidAPPDATA = &H1A ' name>\Application Data
- sfidPRINTHOOD = &H1B ' name>\PrintHood
- sfidLOCAL_APPDATA = &H1C ' name>\Local Settings\Applicaiton Data (non roaming)
- sfidALTSTARTUP = &H1D ' non localizedstartup
- sfidCOMMON_ALTSTARTUP = &H1E ' non localizedCommon startup
- sfidCOMMON_FAVORITES = &H1F
- sfidINTERNET_CACHE = &H20
- sfidCOOKIES = &H21
- sfidHISTORY = &H22
- sfidCOMMON_APPDATA = &H23 ' AllUsers\Application Data
- sfidWINDOWS = &H24 ' GetWindowsDirectory()
- sfidSYSTEM = &H25 ' GetSystemDirectory()
- sfidPROGRAM_FILES = &H26 ' C:\Program Files
- sfidMYPICTURES = &H27 ' C:\Program Files\My Pictures
- sfidMYDOCUMENTS = &H5 ' My Documents => s. a. sfidPERSONAL
- sfidPROFILE = &H28 ' USERPROFILE
- sfidSYSTEMX86 = &H29 ' x86 system directory on RISC
- sfidPROGRAM_FILESX86 = &H2A ' x86 C:\Program Files on RISC
- sfidPROGRAM_FILES_COMMON = &H2B ' C:\Program Files\Common
- sfidPROGRAM_FILES_COMMONX86 = &H2C ' x86 Program Files\Common on RISC
- sfidCOMMON_TEMPLATES = &H2D ' All Users\Templates
- sfidCOMMON_DOCUMENTS = &H2E ' All Users\Documents
- sfidCOMMON_ADMINTOOLS = &H2F ' All Users\Start Menu\Programs\Administrative Tools
- sfidADMINTOOLS = &H30 ' \Start Menu\Programs\Administrative Tools
- sfidProgramFiles = &H10000
- sfidCommonFiles = &H10001
- End Enum
- Private Type SHITEMID
- cb As Long
- abID As Byte
- End Type
- Private Type ITEMIDLIST
- mkid As SHITEMID
- End Type
- Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" _
- Alias "GetUserNameA" (ByVal lpBuffer As String, _
- nSize As Long) As Long
- Private Declare PtrSafe Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA" _
- (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
- Private Declare PtrSafe Function SHGetSpecialFolderLocation Lib _
- "shell32.dll" (ByVal hwndOwner As Long, _
- ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
- Private Declare PtrSafe Function SHGetPathFromIDList Lib _
- "shell32.dll" Alias "SHGetPathFromIDListA" _
- (ByVal pidl As Long, ByVal pszPath As String) As Long
- ' Standard Systemordner ermitteln
- Public Function GetSpecialFolder(CSIDL As SpecialFolderIDs) As String
- ''Aufrufbeispiel:
- ''sPathDesktop = GetSpecialFolder(sfidDESKTOP)
- Dim lResult As Long
- Dim IDL As ITEMIDLIST
- Dim sPath As String
- 10 On Error GoTo GetSpecialFolder_Error
- 20 lResult = SHGetSpecialFolderLocation(100, CSIDL, IDL)
- 30 If lResult = 0 Then
- 40 sPath = Space$(512)
- 50 lResult = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
- 60 GetSpecialFolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
- 70 End If
- 80 On Error GoTo 0
- 90 Exit Function
- GetSpecialFolder_Error:
- 100 MsgBox "Fehlernr.: " & Err.Number & " (" & Err.Description & ") in Prozedur GetSpecialFolder von Modul GetSystemOrdner", , "Fehler in Zeile: " & Erl
- End Function
Und zwar stürzt mein Programm bei folgender Zeile ab in der Funktion GetSpecialFolder
=>
50 lResult = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
Hat einer eine Idee was hier noch zusätzlich geändert werden muss.
Ich vermute es liegt an der Deklaration von
Ich hoffe jemand kann mir hier helfen.
Vielen Dank im Voraus.
Gruß Achilleus
Hallo Leute,
einfach die Suchanfrage in Google umgestellt und schon habe ich die Lösung:
VBA - Office 365 x64 Bit - Vollständiger Absturz - Stack Overflow
VB.NET-Quellcode
- Option Explicit
- ' Ordner-Auflistung
- Public Enum SpecialFolderIDs
- sfidDESKTOP = &H0 ' Desktop
- sfidINTERNET = &H1 ' Internet Explorer (icon on desktop)
- sfidPROGRAMS = &H2 ' Start Menu\Programs
- sfidCONTROLS = &H3 ' My Computer\Control Panel
- sfidPRINTERS = &H4 ' My Computer\Printers
- sfidPERSONAL = &H5 ' My Documents
- sfidFAVORITES = &H6 ' \Favorites
- sfidSTARTUP = &H7 ' StartMenu\Programs\Startup
- sfidRECENT = &H8 ' \Recent
- sfidSENDTO = &H9 ' \SendTo
- sfidBITBUCKET = &HA ' \Recycle Bin
- sfidSTARTMENU = &HB ' \StartMenu
- sfidDESKTOPDIRECTORY = &H10 ' name>\Desktop
- sfidDRIVERS = &H11 ' My Computer
- sfidNETWORK = &H12 ' Network Neighborhood
- sfidNETHOOD = &H13 ' \nethood
- sfidFONTS = &H14 ' windows\fonts
- sfidTEMPLATES = &H15 ' Vorlagen
- sfidCOMMON_STARTMENU = &H16 ' All Users\StartMenu
- sfidCOMMON_PROGRAMS = &H17 ' AllUsers\Programs
- sfidCOMMON_STARTUP = &H18 ' AllUsers\Startup
- sfidCOMMON_DESKTOPDIRECTORY = &H19 ' AllUsers\Desktop
- sfidAPPDATA = &H1A ' name>\Application Data
- sfidPRINTHOOD = &H1B ' name>\PrintHood
- sfidLOCAL_APPDATA = &H1C ' name>\Local Settings\Applicaiton Data (non roaming)
- sfidALTSTARTUP = &H1D ' non localizedstartup
- sfidCOMMON_ALTSTARTUP = &H1E ' non localizedCommon startup
- sfidCOMMON_FAVORITES = &H1F
- sfidINTERNET_CACHE = &H20
- sfidCOOKIES = &H21
- sfidHISTORY = &H22
- sfidCOMMON_APPDATA = &H23 ' AllUsers\Application Data
- sfidWINDOWS = &H24 ' GetWindowsDirectory()
- sfidSYSTEM = &H25 ' GetSystemDirectory()
- sfidPROGRAM_FILES = &H26 ' C:\Program Files
- sfidMYPICTURES = &H27 ' C:\Program Files\My Pictures
- sfidPROFILE = &H28 ' USERPROFILE
- sfidSYSTEMX86 = &H29 ' x86 system directory on RISC
- sfidPROGRAM_FILESX86 = &H2A ' x86 C:\Program Files on RISC
- sfidPROGRAM_FILES_COMMON = &H2B ' C:\Program Files\Common
- sfidPROGRAM_FILES_COMMONX86 = &H2C ' x86 Program Files\Common on RISC
- sfidCOMMON_TEMPLATES = &H2D ' All Users\Templates
- sfidCOMMON_DOCUMENTS = &H2E ' All Users\Documents
- sfidCOMMON_ADMINTOOLS = &H2F ' All Users\Start Menu\Programs\Administrative Tools
- sfidADMINTOOLS = &H30 ' \Start Menu\Programs\Administrative Tools
- sfidProgramFiles = &H10000
- sfidCommonFiles = &H10001
- End Enum
- Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" _
- Alias "GetUserNameA" (ByVal lpBuffer As String, _
- nSize As Long) As Long
- Private Declare PtrSafe Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA" _
- (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
- Private Declare PtrSafe Function SHGetSpecialFolderLocation Lib "shell32.dll" _
- (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As LongPtr) As Long
- Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" _
- Alias "SHGetPathFromIDListA" (ByVal pidl As LongPtr, ByVal pszPath As String) As Boolean
- Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As LongPtr)
- Private Const S_OK As Long = 0
- Private Const MAX_LENGTH = 260
- Public Function GetSpecialFolder(ByVal CSIDL As Integer) As String
- Dim result As Long
- Dim path As String
- Dim idl_ptr As LongPtr
- 'Fill the IDL structure with the specified folder item.
- result = SHGetSpecialFolderLocation(0, CSIDL, idl_ptr)
- If result = S_OK Then
- 'Get the path from the IDL list, and return the folder adding final "\".
- path = Space$(MAX_LENGTH)
- If SHGetPathFromIDList(idl_ptr, path) Then
- GetSpecialFolder = Left$(path, InStr(path, vbNullChar) - 1) & "\"
- End If
- CoTaskMemFree idl_ptr
- End If
- End Function
Gruß Achilleus
Beiträge zusammengefügt. ~Thunderbolt
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Thunderbolt“ ()