Hi,
den Pfad zum Desktop-Link kannst Du über folgenden Tipp ermitteln:
Standard System-Ordner ermitteln
Jetzt brauchst Du nur noch den Namen der LNK-Datei (Verknüpfung) und die ShellExecute-API.
Das ganze sieht dann ungefähr so aus:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Enum SpecialFolderIDs
sfidDESKTOP = &H0
sfidPROGRAMS = &H2
sfidPERSONAL = &H5
sfidFAVORITES = &H6
sfidSTARTUP = &H7
sfidRECENT = &H8
sfidSENDTO = &H9
sfidSTARTMENU = &HB
sfidDESKTOPDIRECTORY = &H10
sfidNETHOOD = &H13
sfidFONTS = &H14
sfidTEMPLATES = &H15
sfidCOMMON_STARTMENU = &H16
sfidCOMMON_PROGRAMS = &H17
sfidCOMMON_STARTUP = &H18
sfidCOMMON_DESKTOPDIRECTORY = &H19
sfidAPPDATA = &H1A
sfidPRINTHOOD = &H1B
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 Function SHGetSpecialFolderLocation Lib _
"shell32.dll" (ByVal hwndOwner As Long, _
ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib _
"shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, ByVal pszPath As String) As Long ' Standard Systemordner ermitteln
Private Function GetSpecialFolder(CSIDL As _
SpecialFolderIDs) As String
Dim lResult As Long
Dim IDL As ITEMIDLIST
Dim sPath As String
lResult = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If lResult = 0 Then
sPath = Space$(512)
lResult = SHGetPathFromIDList(ByVal IDL.mkid.cb, _
ByVal sPath)
GetSpecialFolder = Left$(sPath, InStr(sPath, _
Chr$(0)) - 1)
End If
End Function Private Sub Form_Load()
Me.KeyPreview = True
End Sub Private Sub Form_KeyPress(KeyAscii As Integer)
Dim sPath As String
If KeyAscii = Asc("j") Then
' Pfad zum Desktop
sPath = GetSpecialFolder(sfidDESKTOP)
' Dateiname der Verknüpfung
ShellExecute Me.hWnd, "open", "Name_der_Verknüpfung", "", sPath, 1
End If
End Sub _________________________
Professionelle Entwicklerkomponenten
www.tools4vb.de |