Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

create xp shortcuts

Posted on 2003-03-25
2
Medium Priority
?
274 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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

580 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