vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
vb@rchiv Offline-Reader - exklusiv auf der vb@rchiv CD Vol.4  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: KeyAscii 
Autor: ModeratorDieter (Moderator)
Datum: 05.07.03 01:45

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

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
KeyAscii148xmexPC204.07.03 23:33
Re: KeyAscii409ModeratorDieter04.07.03 23:59
Re: KeyAscii91xmexPC205.07.03 00:52
Re: KeyAscii344ModeratorDieter05.07.03 00:58
Re: KeyAscii94xmexPC205.07.03 01:23
Re: KeyAscii365ModeratorDieter05.07.03 01:27
Re: KeyAscii83xmexPC205.07.03 01:30
Re: KeyAscii77xmexPC205.07.03 01:40
Re: KeyAscii378ModeratorDieter05.07.03 01:45

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel