?
Solved

create xp shortcuts

Posted on 2003-03-25
2
Medium Priority
?
267 Views
Last Modified: 2010-04-17
I have coded in vb6 an installation program and it creates startmenu-programs and desktop shortcuts ok for win95 platform. BUT i also want it to handle winXP, it installs ok and edits registry ok but i need
some example code or AN ANSWER on how to create shortcuts for winXP. Geez a list of whats called
SPECIAL FOLDERS for the SHELL call would be nice....is there any expert that is spiritual enough to help me out please would be muchly appreciated...cheers
0
Comment
Question by:christo7777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 300 total points
ID: 8219924
The below code was pickup from tha allapi network http://www.allapi.net/ the code was modified but will serve as a guide. The code works for W2K XP 98 98se 95 ME (tested). The only problem I have had was when I changed the icons for the ms-dos batch/exe files. If you need that let me know.


Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Long

Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Private Enum Enum_OperatingPlatform
  Platform_Windows_32 = 0
  Platform_Windows_95_98_ME = 1
  Platform_Windows_NT_2K_XP = 2
End Enum

Private Enum Enum_OperatingSystem
  System_Windows_32 = 0
  System_Windows_95 = 1
  System_Windows_98 = 2
  System_Windows_ME = 3
  System_Windows_NT = 4
  System_Windows_2K = 5
  System_Windows_XP = 6
End Enum
Private Sub CreateShortcut()
    Dim lngResult As Long
    Dim ThisDrive As String
    Dim MyWhere As String
    Dim OperSys As Integer '"..\..\Start Menu\Programs\"
    Select Case OperatingSystem
        Case System_Windows_32: OperSys = 0
        Case System_Windows_95: OperSys = 0
        Case System_Windows_98: OperSys = 0
        Case System_Windows_ME: OperSys = 0
        Case System_Windows_NT: OperSys = 0
        Case System_Windows_2K: OperSys = 1
        Case System_Windows_XP: OperSys = 2
    End Select
    MyWhere = "C:\Documents and settings\" & WhoYouAre
    If OperSys = 1 Then
        lngResult = fCreateShellLink("..\..\Desktop", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
    ElseIf OperSys = 2 Then
        lngResult = fCreateShellLink("..\..\Desktop", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
    Else
        lngResult = fCreateShellLink("..\..\Desktop", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
    End If
    If lngResult = 1 Then
        If OperSys = 1 Then
            Call CheckForDirectory(MyWhere & "\Start Menu\Programs\MyApp\")
            lngResult = fCreateShellLink("..\..\Start Menu\Programs\MyApp", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
        ElseIf OperSys = 2 Then
            Call CheckForDirectory(MyWhere & "\Start Menu\Programs\MyApp\")
            lngResult = fCreateShellLink("..\..\Start Menu\Programs\MyApp", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
        Else
            Call CheckForDirectory("C:\windows\Start Menu\Programs\MyApp\")
            lngResult = fCreateShellLink("..\..\Start Menu\Programs\MyApp", "MyApp", "C:\Program files\MyApp\MyApp.exe", "")
        End If
    End If
End Sub

Private Function OperatingSystem() As Enum_OperatingSystem
    Dim lpVersionInformation As OSVERSIONINFO
    lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation)
    Call GetVersionExA(lpVersionInformation)
    If (lpVersionInformation.dwPlatformId = Platform_Windows_32) Then
        OperatingSystem = System_Windows_32
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 0) Then
        OperatingSystem = System_Windows_95
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 10) Then
        OperatingSystem = System_Windows_98
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 90) Then
        OperatingSystem = System_Windows_ME
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion < 5) Then
        OperatingSystem = System_Windows_NT
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 0) Then
        OperatingSystem = System_Windows_2K
    ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 1) Then
        OperatingSystem = System_Windows_XP
    End If
End Function

0
 

Expert Comment

by:CleanupPing
ID: 9446817
christo7777:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question