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

x
?
Solved

VB - Need to create an icon on the desktop - While installing the application created thorugh VB

Posted on 2003-03-24
2
Medium Priority
?
218 Views
Last Modified: 2010-04-17
Hi,

I want to create an icon on the desktop through vb coding. Can you tell me how to create

Also when we install application through the setup.exe created by the package and deployment wizard, it will automatically create a shortcut in the "Start->Programs" panel,  my question is can we create desktop icon for this?.

Pls. tell me how to do that.

Thanks

Chandru.
0
Comment
Question by:s_chandra_prakash
2 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 200 total points
ID: 8219967
Just posted this for someone else. This will check for the operating system and depending on the OS creates shortcuts etc.

I picked up the original code from http://www.allapi.net/ then modified it for what I required. Let me know if you reuire more help.


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: 9446826
s_chandra_prakash:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

581 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