Discussion Locked

Windows Path + Creating Shortcut

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi. I want to develop an installer program (something like installshield) you know? I want to know how it's possible to get windows path and how I can create shortcut. Is there any references? I can't wait to hear from you.

Regards, Ali

7 replies

by tclere

If you are using VB you can use fCreateShellLink() from VB5STKIT.DLL

This test sample uses a network path
\\H4MWN. You can also use C:\MyDir

'<><><><><><><><><><><><><><><><><><><><><>
' This program creates a shortcut on the users desktop.
' NOTE: The file VB5STKIT.DLL must be present
'<><><><><><><><><><><><><><><><><><><><><><>Option Explicit

Private Declare Function fCreateShellLink Lib "Vb5stkit.dll" (ByVal _
lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _
lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long

Sub Main()
Dim lReturn As Long
Dim sDeskName As String
Dim sLinkDesc As String
Dim sLinkPath As String
Dim sLinkArgs As String
On Error GoTo ErrHndlr
'Add to Desktop
sDeskName = "..\..\Desktop"
sLinkDesc = "Shortcut to TestDoc"
sLinkPath = "\\h4mwn\develop\temp\test.doc"
sLinkArgs = ""

lReturn = fCreateShellLink(sDeskName, sLinkDesc, sLinkPath, sLinkArgs)

If

by tclere

Looks like my solution was cut off. Here is the rest of it.

If lReturn = 1 Then
MsgBox "The ShortCut has been added to your Desktop!"
Else
MsgBox "I think there was an error creating the shortcut?"
End If
EndErrHndlr:
sDeskName = "Error No: " & Err.Number & Chr(10) & "Error Desc: " & Err.Description
Err.Clear
MsgBox sDeskName
End
End Sub

by igp

I don't know what language do you want. So now wrote it with Delphi.

Here is answer for WinPath (function)

function GetWindowsFolder:string;
var
TR:TRegIniFile;
HK: HKEY;
begin
RegCreateKey(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows',HK);
Reg:=TRegIniFile.Create('');
Reg.RootKey:=HK;
GetWinVersion:=Reg.ReadString('CurrentVersion','SystemRoot','');
Reg.Free;
end;

Answer about ShellLink I sent to your e-mail (non-visual component).

If you want I can translate it to API.

This discussion is closed to new replies.