誰有客戶端自動更新的程式啊,怎樣做?要完整代碼,謝謝
uj5u.com熱心網友回復:
程式自動更新pb8http://www.hur.cn/Soft/2009/2957.html
程式自動更新
http://www.hur.cn/Soft/2009/2961.html
二層結構的程式實作作業站端自動更新
http://www.hur.cn/Soft/2009/2956.html
uj5u.com熱心網友回復:
這都是什么啊,我想要PB的客戶端程式自動更新、uj5u.com熱心網友回復:
你好,我想知道怎樣得到 本地檔案的日期 和 服務器上對應的檔案日期 兩者進行比較,請高手幫忙,謝謝uj5u.com熱心網友回復:
http://www.sybasebbs.com/forum.php?mod=viewthread&tid=2767&extra=page%3D1參考一下,是根據版本控制的,不是根據日期的。
uj5u.com熱心網友回復:
PB實作客戶端程式的自動升級http://www.hur.cn/Soft/2009/2929.html
c/s應用程式自動升級程式
http://www.hur.cn/Soft/2009/2930.html
其他的自己看吧
http://www.hur.cn/Soft/Search.asp?SoftName=%C9%FD%BC%B6&x=33&y=5
http://www.hur.cn/Soft/Search.asp?ModuleName=Soft&ClassID=0&SpecialID=0&SoftName=%C9%FD%BC%B6&page=2
uj5u.com熱心網友回復:
我想知道怎樣得到 本地檔案的日期 和 服務器上對應的檔案日期 兩者進行比較,請高手幫忙,謝謝uj5u.com熱心網友回復:
以下物件可以取(或者設定)檔案的最后修改時間forward
global type n_cst_liveupdate from nonvisualobject
end type
type os_filedatetime from structure within n_cst_liveupdate
end type
type os_fileopeninfo from structure within n_cst_liveupdate
end type
type os_finddata from structure within n_cst_liveupdate
end type
type os_securityattributes from structure within n_cst_liveupdate
end type
type os_systemtime from structure within n_cst_liveupdate
end type
end forward
type os_filedatetime from structure
unsignedlong ul_lowdatetime
unsignedlong ul_highdatetime
end type
type os_fileopeninfo from structure
character c_length
character c_fixed_disk
unsignedinteger ui_dos_error
unsignedinteger ui_na1
unsignedinteger ui_na2
character c_pathname[128]
end type
type os_finddata from structure
unsignedlong ul_fileattributes
os_filedatetime str_creationtime
os_filedatetime str_lastaccesstime
os_filedatetime str_lastwritetime
unsignedlong ul_filesizehigh
unsignedlong ul_filesizelow
unsignedlong ul_reserved0
unsignedlong ul_reserved1
character ch_filename[260]
character ch_alternatefilename[14]
end type
type os_securityattributes from structure
unsignedlong ul_length
string ch_description
boolean b_inherit
end type
type os_systemtime from structure
unsignedinteger ui_wyear
unsignedinteger ui_wmonth
unsignedinteger ui_wdayofweek
unsignedinteger ui_wday
unsignedinteger ui_whour
unsignedinteger ui_wminute
unsignedinteger ui_wsecond
unsignedinteger ui_wmilliseconds
end type
global type n_cst_liveupdate from nonvisualobject autoinstantiate
end type
type prototypes
//獲得應用程式名用
//Function uint GetModuleFileNameA(ulong hModule,ref string lpFilename,ulong nSize) Library "kernel32.dll" //獲取應用程式運行目錄
//檔案操作
Function long FindFirstFileA (ref string filename, ref os_finddata findfiledata) library "kernel32.dll"
Function boolean FindNextFileA (long handle, ref os_finddata findfiledata) library "kernel32.dll"
Function boolean FindClose (long handle) library "kernel32.dll"
Function long OpenFile (ref string filename, ref os_fileopeninfo of_struct, ulong action) LIBRARY "kernel32.dll"
Function boolean CloseHandle (long file_hand) LIBRARY "kernel32.dll"
Function boolean GetFileTime(long hFile, ref os_filedatetime lpCreationTime, ref os_filedatetime lpLastAccessTime, ref os_filedatetime lpLastWriteTime ) library "kernel32.dll"
Function boolean FileTimeToSystemTime(ref os_filedatetime lpFileTime, ref os_systemtime lpSystemTime) library "kernel32.dll"
Function boolean FileTimeToLocalFileTime(ref os_filedatetime lpFileTime, ref os_filedatetime lpLocalFileTime) library "kernel32.dll"
Function boolean SetFileTime(long hFile, os_filedatetime lpCreationTime, os_filedatetime lpLastAccessTime, os_filedatetime lpLastWriteTime ) library "kernel32.dll"
Function boolean SystemTimeToFileTime(os_systemtime lpSystemTime, ref os_filedatetime lpFileTime) library "kernel32.dll"
Function boolean LocalFileTimeToFileTime(ref os_filedatetime lpLocalFileTime, ref os_filedatetime lpFileTime) library "kernel32.dll"
end prototypes
type variables
end variables
forward prototypes
public function integer of_convertfiledatetimetopb (os_filedatetime astr_filetime, ref date ad_filedate, ref time at_filetime)
public function integer of_convertpbdatetimetofile (date ad_filedate, time at_filetime, ref os_filedatetime astr_filetime)
public function integer of_getcreatedatetime (string as_filename, ref date ad_date, ref time at_time)
public function integer of_getlastwritedatetime (string as_filename, ref date ad_date, ref time at_time)
public function integer of_setlastwritedatetime (string as_filename, date ad_date, time at_time)
public function integer of_convertfiledatetimetopb (os_filedatetime astr_filetime, ref date ad_filedate, ref time at_filetime)
public function integer of_convertpbdatetimetofile (date ad_filedate, time at_filetime, ref os_filedatetime astr_filetime)
public function integer of_getcreatedatetime (string as_filename, ref date ad_date, ref time at_time)
public function integer of_getlastwritedatetime (string as_filename, ref date ad_date, ref time at_time)
public function integer of_setlastwritedatetime (string as_filename, date ad_date, time at_time)
end prototypes
public function integer of_convertfiledatetimetopb (os_filedatetime astr_filetime, ref date ad_filedate, ref time at_filetime);string ls_Date, ls_Time
os_filedatetime lstr_LocalTime
os_systemtime lstr_SystemTime
If Not FileTimeToLocalFileTime(astr_FileTime, lstr_LocalTime) Then Return -1
If Not FileTimeToSystemTime(lstr_LocalTime, lstr_SystemTime) Then Return -1
ls_Date = String(lstr_SystemTime.ui_wyear) + "/" + &
String(lstr_SystemTime.ui_WMonth) + "/" + &
String(lstr_SystemTime.ui_WDay)
ad_FileDate = Date(ls_Date)
ls_Time = String(lstr_SystemTime.ui_wHour) + ":" + &
String(lstr_SystemTime.ui_wMinute) + ":" + &
String(lstr_SystemTime.ui_wSecond) + ":" + &
String(lstr_SystemTime.ui_wMilliseconds)
at_FileTime = Time(ls_Time)
Return 1
end function
public function integer of_convertpbdatetimetofile (date ad_filedate, time at_filetime, ref os_filedatetime astr_filetime);//////////////////////////////////////////////////////////////////////////////
// Protected Function: of_ConvertPBDatetimeToFile
// Arguments: ad_FileDate The file date in PowerBuilder Date format.
// at_FileTime The file time in PowerBuilder Time format.
// astr_FileTime The os_filedatetime structure to contain the system date/time for the file, passed by reference.
// Returns: Integer
// 1 if successful, -1 if an error occurrs.
// Description: Convert PowerBuilder Date and Time to the sytem file type.
//////////////////////////////////////////////////////////////////////////////
// Rev. History: Version
// 6.0 Initial version
// 6.0.01 Fix millisecond overflow. Change size of string to 3 digits from 6
//////////////////////////////////////////////////////////////////////////////
// Copyright ?1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved. Any distribution of the
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
string ls_Date, ls_Time
os_filedatetime lstr_LocalTime
os_systemtime lstr_SystemTime
ls_Date = String(ad_FileDate, "yyyy-mm-dd")
lstr_SystemTime.ui_wyear = Long(Left(ls_Date, 4))
lstr_SystemTime.ui_WMonth = Long(Mid(ls_Date, 6, 2))
lstr_SystemTime.ui_WDay = Long(Right(ls_Date, 2))
ls_Time = String(at_FileTime, "hh:mm:ss:fff")
lstr_SystemTime.ui_wHour = Long(Left(ls_Time, 2))
lstr_SystemTime.ui_wMinute = Long(Mid(ls_Time, 4, 2))
lstr_SystemTime.ui_wSecond = Long(Mid(ls_Time, 7, 2))
lstr_SystemTime.ui_wMilliseconds = Long(Right(ls_Time, 3))
If Not SystemTimeToFileTime(lstr_SystemTime, lstr_LocalTime) Then Return -1
If Not LocalFileTimeToFileTime(lstr_LocalTime, astr_FileTime) Then Return -1
Return 1
end function
public function integer of_getcreatedatetime (string as_filename, ref date ad_date, ref time at_time);//得到檔案創建的時間
long ll_handle
os_finddata lstr_FindData
// Get the file information
ll_handle = FindFirstFileA(as_FileName, lstr_FindData)
If ll_handle <= 0 Then Return -1
FindClose(ll_handle)
// Convert the date and time
Return of_ConvertFileDatetimeToPB(lstr_FindData.str_CreationTime, ad_Date, at_Time)
end function
public function integer of_getlastwritedatetime (string as_filename, ref date ad_date, ref time at_time);//得到檔案最后修改的時間
long ll_handle
os_finddata lstr_FindData
// Get the file information
ll_handle = FindFirstFileA(as_FileName, lstr_FindData)
If ll_handle <= 0 Then Return -1
FindClose(ll_handle)
// Convert the date and time
Return of_ConvertFileDatetimeToPB(lstr_FindData.str_LastWriteTime, ad_Date, at_Time)
end function
public function integer of_setlastwritedatetime (string as_filename, date ad_date, time at_time);boolean lb_Ret
long ll_handle
os_filedatetime lstr_FileTime, lstr_Empty
os_finddata lstr_FindData
os_fileopeninfo lstr_FileInfo
// Get the file information.
// This is required to keep the Last Access date from changing.
// It will be changed by the OpenFile function.
ll_handle = FindFirstFileA(as_FileName, lstr_FindData)
If ll_handle <= 0 Then Return -1
FindClose(ll_handle)
// Convert the date and time
If of_ConvertPBDatetimeToFile(ad_Date, at_Time, lstr_FileTime) < 0 Then Return -1
// Set the file structure information
lstr_FileInfo.c_fixed_disk = "~000"
lstr_FileInfo.c_pathname = as_FileName
lstr_FileInfo.c_length = "~142"
// Open the file
ll_handle = OpenFile ( as_filename, lstr_FileInfo, 2 )
If ll_handle < 1 Then Return -1
lb_Ret = SetFileTime(ll_handle, lstr_Empty, lstr_FindData.str_LastAccessTime, lstr_FileTime)
CloseHandle(ll_handle)
If lb_Ret Then
Return 1
Else
Return -1
End If
end function
on n_cst_liveupdate.create
call super::create
TriggerEvent( this, "constructor" )
end on
on n_cst_liveupdate.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
資料庫中需要存盤檔案的blob,和最后修改日期
uj5u.com熱心網友回復:
樓上的好心人,我想要PB的源程式,我想知道怎樣得到 本地檔案的修改日期 和 服務器上對應的檔案日期 兩者進行比較,希望高手能給清步驟 和代碼,萬分感謝啊、、可以給高分哦 尋找朋友、、uj5u.com熱心網友回復:
他上面的就是源代碼阿...uj5u.com熱心網友回復:
建立一個userobject,命名為n_cst_liveupdate然后對該物件edit source ,將我上面那些內容復制替換掉里面的內容,然后保存
n_cst_liveupdate是一個取(和設定)本地檔案最后修改日期的自定義物件
至于服務器上對應的檔案日期,你必須在資料表中增加一個datatime型別的欄位來記錄檔案的日期
升級檔案最好是只以一個zip型別的壓縮檔案存在(服務器表中記錄的檔案日期以主程式對應的exe的最后修改日期為準),客戶端檢測是否需要升級時,
(1)先獲取本地主程式exe檔案的最后修改日期
(2)獲取服務器升級檔案的最后修改日期
(3)對(1)和(2)中的兩個日期進行判斷,但(1)與(2)之間的時間差在2分鐘(不同的系統對同一個檔案的最后修改日期的獲取會有1到2秒得差距)之內時,不進行升級
(4)需要升級時,將升級檔案下載到臨時檔案夾中,然后使用myzip.dll來解壓
(5)解壓后啟動另一個專門用來升級的exe外掛程式,并關閉主程式
(6)使用升級exe將解壓后的檔案copy到主程式所在的目錄下,替換舊的檔案
(7)替換完畢后,重新啟動主程式,并關閉升級外掛exe
如果主程式需要使用密碼登陸,你可以在啟動升級外掛時,傳入用戶名和密碼。然后升級完畢后,重新啟動主程式時,再將用戶名和密碼重新傳入主程式,主程式根據傳入的用戶名和密碼自動登陸
至于原始碼,你自己完成就可以啦,不難的,主要是取本地檔案的最后修改日期需要用到API(這個我已經給出代碼了),還有解壓縮時也需要呼叫外部dll(myzip的你自己搜索一下,也可以使用extlib.dll),其他的用pb代碼就可以實作啦
uj5u.com熱心網友回復:
大哥 你太厲害了,我不太懂怎么實作,初學PB啊,你能不能加我Q啊,交個朋友,在不打擾的情況下,聊會,QQ:949995014轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/78065.html
標籤:API 調用
下一篇:greenplum 擴容失敗
