Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour,
j'aimerais savoir s'il existe une fonction qui retourne le numéro de la version de l'application que je développe.
Pour pouvoir créer une fenêtre "A propos" dans laquelle sera affiché ce numéro de version.
Merci
Hors ligne
Salut,
Pour moi le numéro de version est une variable d'instance de mon objet application.
Il me suffit d'apeller une fonction qui me permette de récupérer sa valeur pour pouvoir l'afficher sur n'importe quel objet de mon application.
Hors ligne
cela signifie que tu dois modifier ta variable d'instance lorsque tu changes de version si j'ai bien compris ?
Je voudrais arriver a récupérer la version que l'on défini ici :
Hors ligne
tu peux passer par une API qui récupère les infos de l'EXE (comme quand tu fais "propriétés" sur l'EXE)
j'ai trouvé ça : un nvo + une fenêtre about
tu trouveras certainement la fonction externe qui fera ton bonheur :
$PBExportHeader$n_versioninfo.sru forward global type n_versioninfo from nonvisualobject end type end forward global type n_versioninfo from nonvisualobject end type global n_versioninfo n_versioninfo type prototypes FUNCTION ulong GetModuleFileName(ulong hModule, ref string lpFilename, ulong nSize) LIBRARY "KERNEL32.DLL" ALIAS FOR GetModuleFileNameW FUNCTION boolean GetFileVersionInfo(ref string lptstrFilename, ulong dwHandle, ulong dwLen, ref char lpData[]) LIBRARY "VERSION.DLL" ALIAS FOR GetFileVersionInfoW FUNCTION ulong GetFileVersionInfoSize(ref string lptstrFilename, ref ulong lpdwHandle) LIBRARY "VERSION.DLL" ALIAS FOR GetFileVersionInfoSizeW FUNCTION boolean VerQueryValue(char pBlock[], string lpSubBlock, ref ulong lplpBuffer, ref uint pulen) LIBRARY "VERSION.DLL" ALIAS FOR VerQueryValueW end prototypes type variables // this object allows wraps Windows API functions to provide // various version information extracted from an executable // file. For each item of version data, two functions exist: // 1. a no-argument function to provide the information // for the currently executing PowerBuilder application // 2. a one-argument function allowing you to view version // information for any application. (This user object // only implements functions to view information that // can be placed in a PowerBuilder application; however, // additional methods could be added to access version // information that may be present in other EXE files, // such as 'Comments') // strings defined for various version data per the Windows API // (PowerBuilder executables implement only a subset) private CONSTANT STRING VER_COMMENTS = "Comments" private CONSTANT STRING VER_COMPANYNAME = "CompanyName" private CONSTANT STRING VER_FILEDESCRIPTION = "FileDescription" private CONSTANT STRING VER_FILEVERSION = "FileVersion" private CONSTANT STRING VER_INTERNALNAME = "InternalName" private CONSTANT STRING VER_LEGALCOPYRIGHT = "LegalCopyright" private CONSTANT STRING VER_LEGALTRADEMARKS = "LegalTrademarks" private CONSTANT STRING VER_ORIGINALFILENAME = "OriginalFilename" private CONSTANT STRING VER_PRODUCTNAME = "ProductName" private CONSTANT STRING VER_PRODUCTVERSION = "ProductVersion" private CONSTANT STRING VER_PRIVATEBUILD = "PrivateBuild" private CONSTANT STRING VER_SPECIALBUILD = "SpecialBuild" // NULL variables used as arguments in various API calls private string is_null private ulong il_null // BOOLEAN indicating whether or not requested version info is for a PB // application. This is necessary to address the fact that PowerBuilder // stores the information in a non standard way and a slight algorithm // change is required to retrieve version information from a PowerBuilder // generated application versus a third-party application. CR257065 has // been forwarded to Sybase engineering to address this discrepancy. private boolean ib_PBEXE end variables forward prototypes private function string int2hex (integer ai_intvalue, integer ai_pad) public function string getcopyright () public function string getcompanyname (string as_exefile) public function string getcompanyname () public function string getcopyright (string as_exefile) public function string getdescription (string as_exefile) public function string getdescription () public function string getproductname (string as_exefile) public function string getproductname () public function string getversion (string as_exefilename) public function string getversion () public subroutine setispbapp (boolean ab_torf) public function boolean getispbapp () private function string getversioninfo (string as_value, string as_filename) end prototypes private function string int2hex (integer ai_intvalue, integer ai_pad);string ls_hex integer li_nibbleValue // convert a decimal value into its hexadecimal equivalent and pad with // leading zero to the length specified as the second argument to this function DO WHILE ai_intvalue > 0 li_nibbleValue = Mod(ai_intValue, 16) IF li_nibbleValue > 9 THEN ls_hex = CHAR(ASC('A') + (li_nibbleValue - 10)) + ls_hex ELSE ls_hex = String(li_nibbleValue) + ls_hex END IF ai_intvalue = (ai_intValue - li_nibbleValue) / 16 LOOP RETURN Fill("0", ai_pad - Len(ls_hex)) + ls_hex end function public function string getcopyright ();return getCopyright(is_null) end function public function string getcompanyname (string as_exefile);return getVersionInfo(VER_COMPANYNAME, as_exefile) end function public function string getcompanyname ();return getCompanyName(is_null) end function public function string getcopyright (string as_exefile);return getVersionInfo(VER_LEGALCOPYRIGHT, as_exefile) end function public function string getdescription (string as_exefile);return getVersionInfo(VER_FILEDESCRIPTION, as_exefile) end function public function string getdescription ();return getDescription(is_null) end function public function string getproductname (string as_exefile);return getVersionInfo(VER_PRODUCTNAME, as_exefile) end function public function string getproductname ();return getProductName(is_null) end function public function string getversion (string as_exefilename);return getVersionInfo(VER_PRODUCTVERSION, as_exefilename) end function public function string getversion ();return getVersion(is_null) end function public subroutine setispbapp (boolean ab_torf);this.ib_PBEXE = ab_TorF end subroutine public function boolean getispbapp ();return this.ib_PBEXE end function private function string getversioninfo (string as_value, string as_filename);// This function wraps the required API functionality to return // version information for the specified file passed as an // argument. This function will return null if the specified // version information cannot be found or an error occurs in one // of the Windows API calls. Additional, error handling can be added // making use of the GetLastError call in the Windows SDK. ulong ll_size ulong ll_zero string ls_file char lc_cp[4] char lc_verinfo[] uint li_length ulong ll_strAddress string ls_langString // initialize storage for module file name ls_file = Space(256) // get current module file name (null for second parameter indicates current process) IF IsNull(as_fileName) OR (Len(Trim(as_filename)) = 0) THEN IF GetModuleFileName(il_null, ls_file, Len(ls_file)) = 0 THEN RETURN is_null END IF ELSE ls_file = as_fileName END IF // get size of file version info data // N.B., short path form of ls_file on Win95/98/ME must be < 126 characters ll_size = GetFileVersionInfoSize (ls_file, ll_zero) IF ll_size = 0 THEN RETURN is_null END IF // setup space for version information. Since it's a dynamically sized // array of chars, just set last element needed lc_verinfo[ll_size] = Char(0) // get the file version info IF NOT GetFileVersionInfo (ls_file, 0, ll_size, lc_verinfo) THEN RETURN is_null END IF // get FIRST language and code page (if other language strings are specified and required, this // method would require some enhancement and an additional parameter to identify which language/ // code page was desired) IF VerQueryValue(lc_verinfo, "\\VarFileInfo\\Translation", ll_strAddress, li_length) THEN IF (li_length >= 4) THEN // ll_strAddress contains a pointer to a string, so use the address format to resolve the // pointer. Since the string may contain null bytes, and PowerBuilder using a null terminated // string paradigm, we increment the char pointer to retrieve each of the four bytes in the // language/code page sequence lc_cp[1] = String(ll_strAddress, "address") lc_cp[2] = String(ll_strAddress+1, "address") lc_cp[3] = String(ll_strAddress+2, "address") lc_cp[4] = String(ll_strAddress+3, "address") // convert the language / codepage to a string for a subquent lookup. There are two methods // here, one for PB-created executables and one for other third-party executables. CR 257065 // has been opened to remedy the non-standard way that PowerBuilder stores this information. IF this.getIsPBApp() THEN ls_langString = int2Hex(ASC(lc_cp[2]), 2) + int2Hex(ASC(lc_cp[1]), 2) & + int2Hex(Integer(int2Hex(ASC(lc_cp[4]), 2) + int2Hex(ASC(lc_cp[3]), 2)) , 4) ELSE ls_langString = int2Hex(ASC(lc_cp[2]), 2) + int2Hex(ASC(lc_cp[1]), 2) & + int2Hex(ASC(lc_cp[4]), 2) + int2Hex(ASC(lc_cp[3]), 2) END IF ELSE RETURN is_null END IF ELSE RETURN is_null END IF // At this point, extract the specific version information desired and return it as a string IF VerQueryValue(lc_verInfo, "\\StringFileInfo\\" + ls_langString + "\\" + as_value, ll_strAddress, li_length) THEN IF (li_length > 0) THEN RETURN String(ll_strAddress, "address") ELSE RETURN is_null END IF ELSE RETURN is_null END IF end function on n_versioninfo.create call super::create TriggerEvent( this, "constructor" ) end on on n_versioninfo.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;setNull(is_null) setNull(il_null) end event
$PBExportHeader$w_about_application.srw $PBExportComments$Generated about window forward global type w_about_application from window end type type st_1 from statictext within w_about_application end type type st_2 from statictext within w_about_application end type type ocx_rel from statictext within w_about_application end type type shl_2 from statichyperlink within w_about_application end type type shl_1 from statichyperlink within w_about_application end type type copyright from statictext within w_about_application end type type logo from picture within w_about_application end type type st_9 from statictext within w_about_application end type type release from statictext within w_about_application end type type st_11 from statictext within w_about_application end type type st_7 from statictext within w_about_application end type type st_6 from statictext within w_about_application end type type st_5 from statictext within w_about_application end type type company_name from statictext within w_about_application end type type product_name from statictext within w_about_application end type type cb_ok from commandbutton within w_about_application end type end forward global type w_about_application from window integer x = 867 integer y = 429 integer width = 2121 integer height = 1251 boolean titlebar = true string title = " About this program" boolean controlmenu = true windowtype windowtype = response! long backcolor = 15780518 st_1 st_1 st_2 st_2 ocx_rel ocx_rel shl_2 shl_2 shl_1 shl_1 copyright copyright logo logo st_9 st_9 release release st_11 st_11 st_7 st_7 st_6 st_6 st_5 st_5 company_name company_name product_name product_name cb_ok cb_ok end type global w_about_application w_about_application type variables integer ii_picture private n_versioninfo inv_versionInfo end variables forward prototypes public subroutine wf_get_exe_info () end prototypes public subroutine wf_get_exe_info ();string ls_PropertyValue string program_name // if the EXE SLE is blank, assume it's the currently running process // and set the EXE name to NULL to indicate that setNull(program_name) // set the indicator value as to whether this is or is not a PB-generated application inv_versionInfo.setIsPBApp(TRUE) // get and display the various version information strings (the string <NULL> displays if the // version information was not accessible based on the information not being stamped within // the EXE file or because of a programming error). ls_PropertyValue = inv_versionInfo.getProductName(program_name) if IsNull(ls_PropertyValue) THEN ls_PropertyValue = "<NULL>" product_name.text = ls_PropertyValue ls_PropertyValue = inv_versionInfo.getDescription(program_name) if IsNull(ls_PropertyValue) THEN ls_PropertyValue = "<NULL>" w_about_application.title = ls_PropertyValue ls_PropertyValue = inv_versionInfo.getCompanyName(program_name) if IsNull(ls_PropertyValue) THEN ls_PropertyValue = "<NULL>" company_name.text = ls_PropertyValue ls_PropertyValue = inv_versionInfo.getCopyright(program_name) if IsNull(ls_PropertyValue) THEN ls_PropertyValue = "<NULL>" copyright.text = "(C) by "+ls_PropertyValue ls_PropertyValue = inv_versionInfo.getVersion(program_name) if IsNull(ls_PropertyValue) THEN ls_PropertyValue = "<NULL>" release.text = "Release "+ls_PropertyValue+ & " - "+string(PBCompileDate)+" "+string(PBCompileTime)+ & " - PB "+string(pb_env.PBMajorRevision)+"."+string(pb_env.PBMinorRevision)+"."+ & string(pb_env.PBFixesRevision)+"."+string(pb_env.PBBuildNumber) end subroutine on w_about_application.create this.st_1=create st_1 this.st_2=create st_2 this.ocx_rel=create ocx_rel this.shl_2=create shl_2 this.shl_1=create shl_1 this.copyright=create copyright this.logo=create logo this.st_9=create st_9 this.release=create release this.st_11=create st_11 this.st_7=create st_7 this.st_6=create st_6 this.st_5=create st_5 this.company_name=create company_name this.product_name=create product_name this.cb_ok=create cb_ok this.Control[]={this.st_1,& this.st_2,& this.ocx_rel,& this.shl_2,& this.shl_1,& this.copyright,& this.logo,& this.st_9,& this.release,& this.st_11,& this.st_7,& this.st_6,& this.st_5,& this.company_name,& this.product_name,& this.cb_ok} end on on w_about_application.destroy destroy(this.st_1) destroy(this.st_2) destroy(this.ocx_rel) destroy(this.shl_2) destroy(this.shl_1) destroy(this.copyright) destroy(this.logo) destroy(this.st_9) destroy(this.release) destroy(this.st_11) destroy(this.st_7) destroy(this.st_6) destroy(this.st_5) destroy(this.company_name) destroy(this.product_name) destroy(this.cb_ok) end on event close;// destroy version info structure DESTROY inv_versionInfo end event event open;// create NVO to be used to access the version information inv_versionInfo = CREATE n_versionInfo wf_get_exe_info () end event type st_1 from statictext within w_about_application integer x = 40 integer y = 848 integer width = 325 integer height = 58 integer textsize = -7 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Trebuchet MS" long textcolor = 16711680 long backcolor = 15780518 string text = "Report bugs to:" boolean focusrectangle = false end type type st_2 from statictext within w_about_application integer x = 1357 integer y = 317 integer width = 325 integer height = 58 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "Tn activex R:" boolean focusrectangle = false end type type ocx_rel from statictext within w_about_application integer x = 1737 integer y = 310 integer width = 340 integer height = 74 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 65535 long backcolor = 8388608 boolean enabled = false string text = "ocx_release" alignment alignment = center! boolean border = true borderstyle borderstyle = styleshadowbox! boolean focusrectangle = false end type event constructor;this.text=gs_ole_tn_release end event type shl_2 from statichyperlink within w_about_application integer x = 377 integer y = 848 integer width = 406 integer height = 58 integer textsize = -7 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Trebuchet MS" boolean underline = true string pointer = "HyperLink!" long textcolor = 134217856 long backcolor = 15780518 string text = "sysi...@becromal.it" boolean focusrectangle = false end type event clicked;run("rundll32 url.dll,FileProtocolHandler " + & "mailto:"+shl_2.text+"?subject="+ & product_name.text + " " + release.text ) end event type shl_1 from statichyperlink within w_about_application integer x = 44 integer y = 784 integer width = 552 integer height = 58 integer textsize = -7 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Trebuchet MS" boolean underline = true string pointer = "HyperLink!" long textcolor = 134217856 long backcolor = 15780518 string text = "http://www.becromal.com" boolean focusrectangle = false string url = "http://www.becromal.com" end type type copyright from statictext within w_about_application integer x = 29 integer y = 1082 integer width = 2052 integer height = 74 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Trebuchet MS" long textcolor = 65535 long backcolor = 8388608 string text = "none" boolean border = true borderstyle borderstyle = styleshadowbox! boolean focusrectangle = false end type type logo from picture within w_about_application integer x = 33 integer y = 368 integer width = 457 integer height = 400 boolean originalsize = true string picturename = "..\pic\becromal.bmp" boolean border = true borderstyle borderstyle = styleshadowbox! boolean focusrectangle = false end type type st_9 from statictext within w_about_application integer x = 40 integer y = 944 integer width = 1671 integer height = 93 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Trebuchet MS" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "ALUMINIUM FOIL FOR ELECTROLYTIC CAPACITORS" boolean focusrectangle = false end type type release from statictext within w_about_application integer x = 315 integer y = 192 integer width = 1759 integer height = 74 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 65535 long backcolor = 8388608 boolean enabled = false string text = "release" alignment alignment = center! boolean border = true borderstyle borderstyle = styleshadowbox! boolean focusrectangle = false end type type st_11 from statictext within w_about_application integer x = 51 integer y = 195 integer width = 241 integer height = 64 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "Release:" boolean focusrectangle = false end type type st_7 from statictext within w_about_application integer x = 530 integer y = 653 integer width = 464 integer height = 77 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "(Fax +39 2 57512067)" boolean focusrectangle = false end type type st_6 from statictext within w_about_application integer x = 534 integer y = 576 integer width = 497 integer height = 54 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "(Tel. +39 2 892131)" boolean focusrectangle = false end type type st_5 from statictext within w_about_application integer x = 538 integer y = 499 integer width = 1554 integer height = 58 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "Via E.CH.Rosenthal, 5 - 20089 Quinto De Stampi - Rozzano - MI - Italy" boolean focusrectangle = false end type type company_name from statictext within w_about_application integer x = 538 integer y = 413 integer width = 980 integer height = 96 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 8388608 long backcolor = 15780518 boolean enabled = false string text = "company_name" boolean focusrectangle = false end type type product_name from statictext within w_about_application integer x = 18 integer y = 22 integer width = 2052 integer height = 102 integer textsize = -16 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 65535 long backcolor = 8388608 boolean enabled = false string text = "product name" alignment alignment = center! boolean border = true borderstyle borderstyle = styleshadowbox! boolean focusrectangle = false end type type cb_ok from commandbutton within w_about_application integer x = 1851 integer y = 851 integer width = 212 integer height = 182 integer taborder = 1 integer textsize = -8 integer weight = 700 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" string text = "OK" boolean default = true end type on clicked;/* Close "About" window */ Close (Parent) end on
Hors ligne