PDA

View Full Version : سوال: طریقه ساخت شورتکات



Mitra_folati
دوشنبه 16 اسفند 1389, 19:08 عصر
سلام به همه


من چطوری می تونم با کد نویسی از برنامه خودم و یا سایر برنامه های نصب شده شورت کات ایجاد کنم؟

از همتون ممنونم.

parselearn
دوشنبه 16 اسفند 1389, 23:58 عصر
http://www.knowdotnet.com/articles/createshortcutondesktop.html
http://www.tek-tips.com/faqs.cfm?fid=6127



2- پنجره رفرنس را باز نمائيد
3- سربرگ Com را انتخاب كنيد سپس Windows Script Host Object Model را علامت بزنيد
4- سپس IWshRuntimeLibrary را ايمپورت نمائيد





Step 1. Create a new VB .NET project or open an existing one.
Step 2. Right-click 'References' in the Solution Explorer and click 'Add reference...'
Step 3. Select the 'COM' tab and scroll down to 'Windows Script Host Object Model'. Click 'OK' and a reference to 'IWshRuntimeLibrary' should be added.
Step 4. Open the form or class you wish to write your code in for adding the shortcut and add the next line at the top:


Imports IWshRuntimeLibrary

Step 5. Add the following function to your class:



Private Function CreateShortCut(ByVal shortcutName As String, ByVal creationDir As String, ByVal targetFullpath As String, ByVal workingDir As String, ByVal iconFile As String, ByVal iconNumber As Integer) As Boolean
Try
If Not IO.Directory.Exists(creationDir) Then
Dim retVal As DialogResult = MsgBox(creationdir & " does not exist. Do you wish to create it?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo)
If retVal = DialogResult.Yes
IO.Directory.CreateDirectory(creationDir)
Else
Return False
End If
End If

Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(wShell.CreateShortcut(creationDir & "\" & shortcutName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = targetFullpath
shortCut.WindowStyle = 1
shortCut.Description = shortcutName
shortCut.WorkingDirectory = workingDir
shortCut.IconLocation = iconFile & ", " & iconNumber
shortCut.Save()
Return True
Catch ex As System.Exception
Return False
End Try
End Function




The CreateShortCut function requires 6 parameters:
- shortCutName : The name of the shortcut
- creationDir : The folder where the shortcut should be created
- targetFullpath : The full path to the target file
- workingDir : The folder to use as working directory for the target of the shortcut
- iconFile : The file that contains the icon for the shortcut
- iconNumber : The position of the icon within the icon file. This is zero if the icon file is an icon itself.

The function returns false if the creation of a shortcut has failed. An example of calling the function:



myBool = CreateShortCut("My Application", System.Environment.GetFolderPath(Environment.Speci alFolder.Desktop), Application.ExecutablePath, Application.StartupPath, "myAppExtensions.dll", 4)

ali_najari
سه شنبه 17 اسفند 1389, 00:01 صبح
دوست عزیز سایت های زیر رو یک نگاهی بندازید:

http://www.knowdotnet.com/articles/createshortcutondesktop.html

http://www.vbforums.com/showthread.php?t=234891

http://www.tek-tips.com/viewthread.cfm?qid=1088541&page=1

http://www.tek-tips.com/faqs.cfm?fid=6127

Mitra_folati
سه شنبه 17 اسفند 1389, 05:32 صبح
از دوستان خیلی ممنونمولی نمی دونم عبارتهای sWorkPath و یا WorkPath در سایت زیر به چه دردی میخوره؟!!!

http://www.vbforums.com/showthread.php?t=234891

همچنین در سایت بالا محل های تولید شورتکات بهصورت زیر بیان شده اما فقط دسکتاب کار میکنهو بقیش کار نمیکنه!!!





"Desktop :Our Desktop
Programs :Start Menu\Programs
StartMenu :Start Menu
StartUp :Start Menu\Programs\StartUp
SendTo :Windows\SentTo
Fonts :Windows\Fonts
Favorites :Windows\Favorites"




در پایان ضمت تشکر از دوستان این نکته رو می گم که از کل سایتهائس که دوستان معرفی کردند فقط همین یکدونه مفید بود در مورد سایر سایتها به نتیجه نرسیدم.و شاید هم من نتونستم درست استفاده کنم اگر ممکنه دوستان راهنمائی کنند.


-----------------------------------------------------------------------------------------------------------------------------------

Reza,M
چهارشنبه 18 اسفند 1389, 15:04 عصر
با سلام دوستان ميشه نمونه بزاريد ! جواب نگرفتم ؟