NiX
|
****** ** - BRASIL
|
|
ENUNCIADA !
|
|
|
Postada em 31/12/2005 16:36 hs
E ae amigos minha dúvida é a seguinte, queria saber se tem como criar uma atalho do aplicativo via código na area de trabalho e tbm queria saber se tem como copiar um determinado arquivo para area de trabalho tbm( no win98 seria fácio mais como faria tipo no xp tem usuarios diferentes?) Valeu galera
|]|[|]|[|]|[|]|[|]|[|]|[| NiX |]|[|]|[|]|[|]|[|]|[|
|
|
|
|
Geronimo
|
JOINVILLE SC - BRASIL
|
|
ENUNCIADA !
|
|
|
Postada em 21/01/2006 06:52 hs
'************************************** ' Name: Create a real folder shortcut ' Description:Ever try to create a "Fold ' er" shortcut in Visual Basic, like the s ' hortcut in My Network Places. This code ' will allow you to create a folder shortc ' ut the same way Microsoft creates them. ' By: Michael Kempf ' ' AUTHOR:Kemtech Software ' ' PURPOSE:These functions will allow you ' to create a real Folder Shortcut not a 'standard file folder shortcut
Option Explicit
' PROCEDURE: CreateShortcut ' ' AUTHOR:Kemtech Software1/21/2003 9:17: ' 30 AM ' ' PURPOSE:Creates a shortcut in a specif ' ied location ' ' PARAMETERS: '[in]strPath(String) = Path to the file ' or folder to create a shortcut '[in]strFolder(String) = Folder to creat ' e the shortcut in ' ' ' RETURN:Boolean - True/False - Successf ' ul completion. ' '/////////////////////////////////////// ' //////////////////////////////////////// ' ////////////
Public Function CreateShortcut(strPath As String, strFolder As String, Optional strLinkName As String) As Boolean Dim strSvrName As String Dim strFldrNameAs String Dim objwShell, objShortCut Set objwShell = CreateObject("Wscript.Shell") 'iF NO NAME SPECIFIED THEN CREATE THE DE ' FAULT NAME
If strLinkName = "" Then 'Create a Link Name from the Path
If Left(strPath, 2) = "\" Then 'UNC Name strSvrName = Mid(strPath, 3, InStr(Mid(strPath, 3), "") - 1) strFldrName = Right(strPath, Len(strPath) - InStrRev(strPath, "")) Else strSvrName = Left(strPath, 1) strFldrName = Right(strPath, Len(strPath) - InStrRev(strPath, "")) End If strLinkName = strFldrName & " On " & strSvrName End If 'Create the new folder On Error Resume Next MkDir (strFolder & "" & strLinkName) strFolder = strFolder & "" & strLinkName 'Create the target shortcut shortcut Set objShortCut = objwShell.CreateShortcut(strFolder & " arget.lnk") objShortCut.TargetPath = strPath objShortCut.Description = strPath objShortCut.Save CreateDesktopINI (strFolder) 'Set the file attributes for the shortcu ' ts folder SetAttr strFolder, vbReadOnly Set objwShell = Nothing Set objShortCut = Nothing End Function '/////////////////////////////////////// ' //////////////////////////////////////// ' //////////// ' PROCEDURE: CreateDesktopINI ' ' AUTHOR:Kemtech Software1/21/2003 9:17: ' 30 AM ' ' PURPOSE:Creates a shortcut in a specif ' ied location ' ' PARAMETERS: '[in]strPath(String) = Path where to cre ' ate the desktop.ini file in ' ' ' RETURN:none ' '/////////////////////////////////////// ' //////////////////////////////////////// ' ////////////
Public Function CreateDesktopINI(strPath As String) 'Check to see if there is a backslash at ' the end of the path
If Not Right(strPath, 1) = "" Then strPath = strPath & "" End If 'The desktop.ini file points to the clsi ' d in the system registry for the folder ' shortcut. Open strPath & "desktop.ini" For Output As #1 Print #1, "[.ShellClassInfo]" Print #1, "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" Print #1, "Flags = 2" Print #1, "ConfirmFileOp = 0" Close #1 End Function
O exemplo do Pascoal cria um atalho de pasta e o meu de arquivo:
Public Sub CreateLink(ByVal sLinkPath As String, ByVal sName As String, ByVal sPath As String, Optional HotKey As String = "", Optional sIcon As String = "", Optional sWorkingDirectory As String = "", Optional sSubFolder As String = "", Optional iWinStyle As Integer = vbNormalFocus)
Dim WshShell As Object Dim oShellLink As Object Set WshShell = CreateObject("WScript.Shell") On Error Resume Next If sSubFolder <> "" Then sLinkPath = sLinkPath & "" & sSubFolder If Dir(sLinkPath) = "" Then MkDir sLinkPath End If On Error GoTo 0 Set oShellLink = WshShell.CreateShortcut(sLinkPath & "" & sName & ".lnk") oShellLink.WindowStyle = iWinStyle oShellLink.HotKey = sHotKey oShellLink.TargetPath = sPath oShellLink.IconLocation = sIcon oShellLink.Description = sName oShellLink.WorkingDirectory = sWorkingDirectory oShellLink.Save Set oShellLink = Nothing Set WshShell = Nothing End Sub
Exemplo:
CreateLink "c:", "Calculadora", "c:windowscalc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:windows"
"O pior inimigo que você poderá encontrar será sempre você mesmo."
|
|
|
|
Postada em 21/03/2006 15:46 hs
Olá Pessoal! Para criar um atalho do seu programa no Desktop do Windows com a Descrição correta e tecla de ataho, preparei a subrotina abaixo, fácil e descomplicada. Private Sub CriaAtalhoDesktop(pDescr As String, pFullPathPgm As String, Optional pAtalhoKey As String = "", Optional pAtalhoParams As String = "") Dim WshShell As Object, oShellLink As Object Dim strDesktop As String, strLink As String, WorkPath As String WorkPath = Left(pFullPathPgm, InStrRev(pFullPathPgm, "")) Set WshShell = CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") strLink = strDesktop & "" & pDescr & ".lnk" Set oShellLink = WshShell.CreateShortcut(strLink) oShellLink.TargetPath = pFullPathPgm oShellLink.HotKey = pAtalhoKey oShellLink.Arguments = pAtalhoParams oShellLink.WorkingDirectory = WorkPath oShellLink.Description = pDescr oShellLink.Save End Sub Exemplo: Call CriaAtalhoDesktop("Programa de Estoque", "C:EstoqueMeuPgm.exe", "CTRL+SHIFT+E", "Parametros") Espero ter colaborado. Luis
|
|
|
Daniel
|
SÃO PAULO SP - BRASIL
|
|
ENUNCIADA !
|
|
|
Postada em 21/03/2006 16:09 hs
MUito Legal, Luis, funcionou direitinho, beleza
dsmn
|
|
|
Daniel
|
SÃO PAULO SP - BRASIL
|
|
ENUNCIADA !
|
|
|
Postada em 21/03/2006 16:09 hs
Legal Luis, testei o seu exemplo e funciona perfeitamente.
dsmn
|
|
|
|