 |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
Ruey
註冊時間: 2003-03-12 文章: 1698 來自: tunglo
第 1 樓
|
發表於: 星期一 三月 15, 2004 2:10 am 文章主題: 看老外如何發佈新VFP執行文件(轉貼) |
|
|
來源:myf1 不會
http://www.myf1.net/bbs/dispbbs.asp?BoardID=1&id=243396&replyID=254232&star=1&skin=
看老外如何發佈新VFP執行文件 (絕無隱藏炸彈!)
如果你的VFP 程序名為 myFile.exe, 等有新版本時,常常因為用戶正在使用,而無法覆蓋
現有的文件名。那麼不妨將新版文件命名為 myFile02.exe, myFile03.exe ....... 依此類推,拷貝到同一個目錄下。
用戶每次還是執行 myFile.exe , 只是裡面的內容變了,是如下一個 prg 文件,你將其編譯為目前的可執行文件名就是了。(另一好處是自己從新版文件名也大概知道目前的版本。)
代碼: |
* Generic loader program.
LOCAL lcExecPath, lcFileName, lcSkeleton, lnFileCount
LOCAL lcExe, ltLatest, lnI
LOCAL ARRAY laFiles(1)
* Get the path to the executable directory
lcExecPath = JUSTPATH(SYS(16))
* Make that the default
SET DEFAULT TO (lcExecPath)
* Get the root name of the exectuable program
lcFileName = JUSTSTEM(SYS(16))
* Build an array of all possible EXE names
lcSkeleton = lcFileName+"??.EXE"
&& lcSkeleton is the wildcard
&& file spec for ADIR()
lnFileCount = ADIR(laFiles,lcSkeleton)
* Look for the most recent EXE file
lcEXE = ""
ltLatest = {}
FOR lnI = 1 TO lnFileCount
IF FDATE(laFiles(lnI,1),1) > ltLatest
ltLatest = FDATE(laFiles(lnI,1),1)
lcExe = laFiles(lnI,1)
ENDIF
ENDFOR
* Launch the most recent EXE file
IF NOT EMPTY(lcExe)
DO (lcEXE)
ENDIF |
_________________ #############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!
學會VFP使用者社區的搜尋,Code才會更有趣~
############################# |
|
回頂端 |
|
 |
Ruey
註冊時間: 2003-03-12 文章: 1698 來自: tunglo
第 2 樓
|
發表於: 星期一 三月 15, 2004 2:29 am 文章主題: |
|
|
原文如下:
Title:Installing New Copies of Visual FoxPro Executables
如何安裝VFP執行文件的新拷貝
Learn how to install updated VFP .EXE files without forcing users to log out of your application.
學習如何安裝更新的VFP EXE文件,而無需強制用戶退出你的應用程序
By Mike Lewis, Director, Mike Lewis Consultants Ltd.
Have you ever needed to install a new copy of an .EXE file after an application has gone live? If so, you know that you can't simply copy the new file over the existing one. If you try to do that while users are running the application, Windows will report a file sharing violation. Your only recourse will be to wait until everyone has logged out, which could be inconvenient.
你是否遇到過當程序運行時你卻需要安裝EXE文件的新拷貝?若是,你就會知道不能簡單的複製新文件以覆蓋所存在的舊文件。當用戶運行程序時如果你這樣做,Windows系統就會報告文件共享出錯。你只能等待一直到所有的用戶退出,這非常不方便。
Andrew Connor, the IT manager at Mids & Horsey Ltd. in the United Kingdom, has come up with a simple solution to this problem. Andrew suggests that you supply a small loader program that searches the executable directory for the latest version of the .EXE file. After the program finds the latest version, it hands over control to that file and thus runs the application in the normal way.
Andrew Connor是英國Mids & Horsey公司的IT經理,他有一個解決這個總是的簡單辦法。Andrew建議你提供地個小的引導程序,用以在運行目錄搜索EXE可執行文件的最新版本文件。在程序找到最新版本後,它將控制權移交給這個文件,並且以普通方式來運行此文件。
The loader program is a simple Visual FoxPro .PRG. It's completely generic -- it doesn't have to know the name of the target .EXE file or the directory that contains it. However, you do need to follow a simple naming convention.
引導程序是一個簡單的VFP PRG程序,它非常普通,它不必要知道目標EXE文件名和它所在的目錄。然而,你只需要給出一個簡單的命名規範。
Naming the files
命名文件
You must compile the loader program into an .EXE file, the name of which must be that of the main application. This is the file users will launch when they want to run the application.
你必須將引導程序編譯為EXE執行文件,並且必須與主應用程序同名。這是用戶所運行的,並且將會你的應用程序。
For the name of the application's actual .EXE file, use the application name followed by a two-digit version number. So, if the application is called SALES, the loader program will be SALES.EXE. The main .EXE file, then, might be SALES01.EXE, SALES02.EXE, and so on. Each time you want to distribute a new version of the main .EXE, just change the version number.
應用程序的EXE文件的實際文件名,用應用程序名後跟隨兩位版本號。於是,如果應用程序名為SALES,引導程序就是SALES.EXE,EXE主程序文件,將會是SALES01.EXE、SALES02.EXE,等等。每次你想要發佈主程序文件的一個新版本時,你只需要改變版本號。
Your version numbers can be any numbers you like. They don't have to be consecutive or in ascending order, but they must always be exactly two digits.
你的版本號可以是你所喜歡的任何數字,不要求是連續或遞增的,但必須是正好兩位數字。
Be sure to place the loader's .EXE file in the same directory as the main executable file. Then simply arrange for the users to run the loader whenever they want to launch the application.
確保引導程序與主程序文件在同一個目錄下。然後只需要用戶要運行應用程序時直接運行引導程序就可。
The code
代碼
Here, then, is the code for the loader program. You can paste this code into a .PRG file and then build it to an .EXE.
這裡是引導程序的代碼。你可以將此代碼粘貼到一個PRG文件,再編譯為一個EXE文件。
* Generic loader program.
* 普通引導程序
LOCAL lcExecPath, lcFileName, lcSkeleton, lnFileCount
LOCAL lcExe, ltLatest, lnI
LOCAL ARRAY laFiles(1)
* Get the path to the executable directory
* 取得執行文件的目錄
lcExecPath = JUSTPATH(SYS(16))
* Make that the default
* 設置默認目錄
SET DEFAULT TO (lcExecPath)
* Get the root name of the exectuable program
* 取得執行文件的主文件名
lcFileName = JUSTSTEM(SYS(16))
* Build an array of all possible EXE names
* 建立一個數組以保存所有的EXE文件名
lcSkeleton = lcFileName+"??.EXE"
&& lcSkeleton is the wildcard
&& file spec for ADIR()
lnFileCount = ADIR(laFiles,lcSkeleton)
* Look for the most recent EXE file
* 查找最新的EXE文件
* [譯注]此程序裡以文件的最新修改日期來判斷程序文件的版本新舊
* 也可以對此略作修改以直接通過文件名後的版本號來作判斷
lcEXE = ""
ltLatest = {}
FOR lnI = 1 TO lnFileCount
IF FDATE(laFiles(lnI,1),1) > ltLatest
ltLatest = FDATE(laFiles(lnI,1),1)
lcExe = laFiles(lnI,1)
ENDIF
ENDFOR
* Launch the most recent EXE file
* 執行此最新的文件
IF NOT EMPTY(lcExe)
DO (lcEXE)
ENDIF
As you can see, the loader program builds an array containing the names of all the .EXE files that follow the naming convention. It then hands over control to the most recent of those files.
正如你所見到的,引導程序建立一個數組以保存所有符合此命名規範的EXE文件名,然後它將控制權轉移到此最新的文件。
Updating the application
更新應用程序
From now on, whenever you want to distribute a new version of the application, you can just copy the updated .EXE file to the executable directory. Because this will have a different version number from the existing file, you can do this even while the users are working in the application. The next time a user launches the application, the loader will automatically find the correct version. In due course, you can delete the old version.
現在,當你要發佈應用程序的新版本時,你只需要複製一個更新的EXE文件到運行目錄。因為所有的文件都有不同的版本號,這樣即使用戶在運行時你也可以操作。下一次當用戶運行應用程序時,引導就會自動找到正確的版本。因此,你就可以刪除舊的版本。 _________________ #############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!
學會VFP使用者社區的搜尋,Code才會更有趣~
############################# |
|
回頂端 |
|
 |
syntech
註冊時間: 2003-05-16 文章: 4249 來自: Taipei,Taiwan
第 3 樓
|
發表於: 星期一 三月 15, 2004 10:30 am 文章主題: |
|
|
真巧,
去年用BCB版系統主menu呼叫VFP 子系統程式時,
也作了同樣的東西,
也是取得該目錄所有按照公司規定名稱命名方式的EXE檔,
取出數字最大者(latest)執行 _________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙 |
|
回頂端 |
|
 |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|