PDA

View Full Version : ساختن ShortCut



rezaTavak
جمعه 21 فروردین 1383, 15:23 عصر
سلام

می خواستم بدونم کسی از داخل فاکس پرو بلده Shortcut بساز یعنی با دستورات؟

kia1349
شنبه 22 فروردین 1383, 07:08 صبح
راه اول


---------------------------------------------------------------------------------------
* DCC - This program assumes that you have passed a correct Target Path and Short cut name.
* DCC - This program is merely for demonstration purposes. There are no guarantees that this code is bug free and
* DCC - it should be treated as such.

* DCC - Sample call DO CreateShortCut WITH "Notepad.lnk", "notepad.exe"
* DCC - Sample call DO CreateShortCut WITH "Microsoft Web Site.URL", "http://www.microsoft.com"

LPARAMETERS tcShortCutName, tcTargetPath
LOCAL lcxDirectory, loWshShell, loShortCut, llNormalShortCut

* DCC - Save current directory.
lcxDirectory = SET("Directory")

* DCC - Get extension. Determine if this is a URL shortcut or a normal (lnk) shortcut.
lcExt = UPPER( ALLTRIM( JUSTEXT( tcShortCutName ) ) )
llNormalShortCut = ( lcExt == "LNK" )

* DCC - Create your windows scripting host (WSH) shell to enable a move to the desk top directory
loWshShell = CreateObject( "WScript.Shell" )
SET DIRECTORY TO (loWshShell.SpecialFolders("Desktop"))

* DCC - Use your WSH object to create your shortcut.
loShortCut = loWshShell.CreateShortcut( tcShortCutName )
* DCC - Set your properties and save the shortcut
loShortCut.TargetPath = tcTargetPath

* DCC - The following properties are only available for normal short cuts.
IF llNormalShortCut

* DCC - Below are other properties and examples of setting them.
loShortCut.IconLocation = "notepad.exe, 0"
loShortCut.Description = "Currently running script."
loShortCut.Hotkey = "ALT+CTRL+F"
loShortCut.WindowStyle = 7 && minimized
loShortCut.WorkingDirectory = "c:\"

* DCC - Display full path of the executable
?loShortCut.Fullname

ENDIF

* DCC - Must save the short cut. The short cut saves in the current directory, which is why we moved to the directory
* DCC - prior to creating the shortcut.
loShortCut.Save

* DCC - Now move back to your starting directory
SET DIRECTORY TO (lcxDirectory)
---------------------------------------------------------------------------------------
راه دوم
--------------------------------------------------------------------------------------


*!* CreateStartupShortcut.PRG
*!*
*!* Adapted from Microsoft Knowledgebase Article Q244677
*!* http://support.microsoft.com/default.aspx?scid=kb;EN-US;q244677
*!*
*!* For using the Windows Script Host, please read the excellent series
*!* by George Tasker and Ed Rauh that is available at http://www.vfug.org.
*!* The series started September, 2000.
*!*
*!* Nancy Folsom
*!* Pixel Dust Industries
*!* http://www.pixeldustindustries.com
*!*
*!* 2002.03.07
*!*
#DEFINE SC_MAXIMIZED 3
#DEFINE SC_MINIMIZED 7
#DEFINE SC_NORMAL 4

#IF VERSION() = "Visual FoxPro 06.00.8961.00 for Windows"
LOCAL ;
loWsh, ;
lcFolder, ;
loShortCut, ;
lcAppPath
#ELSE
LOCAL ;
loWsh AS Wscript.SHELL, ;
lcFolder, ;
loShortCut, ;
lcAppPath
#ENDIF

*!* Create the Windows Script Host
loWsh = CREATEOBJECT("Wscript.shell")

*!* Locate the user's start up folder
lcFolder = loWsh.SpecialFolders("StartUp")

*!* Create a shortcut object
loShortCut= loWsh.CreateShortcut(lcFolder + "\POS.lnk")

*!* Set the properties of the shortcut. Note that no error occurs if
*!* one of the parameters is wrong. The shortcut just won't be saved.
*!* Also, if the shortcut already exists, it will be overwritten w/o
*!* warning.
*!*
lcAppPath = FULLPATH(CURDIR()) && For example
lcAppName = "MyApp.EXE" && For example

loShortCut.WorkingDirectory = lcAppPath
loShortCut.TargetPath = '"' + lcAppPath + lcAppName + '"'
loShortCut.IconLocation = loShortCut.TargetPath && Assumes built-in ICO
loShortCut.WindowStyle = SC_MAXIMIZED

loShortCut.HOTKEY = "ALT+CTRL+P" && For example

*!* Save the shortcut
loShortCut.SAVE()
--------------------------------------------------------------------------------------

rezaTavak
یک شنبه 23 فروردین 1383, 13:48 عصر
سلام

ممنون. :)