Skip to Content
0

ProfileString behaviour in PB12.6 (B4091)

Dec 12, 2016 at 05:23 AM

136

avatar image
Former Member

Hi All,

We see different behaviour of ProfileString() in PB12.6 (B4091).

While accessing WIN.INI using ProfileString() function in PowerBuilder, PB fetches only C:\Windows\Win.ini file. We didn't specify path in this function. We used below command -
ProfileString("WIN.INI", ls_proj_name, "INIPATH", "")


In PB12.5 we ideally set below environment variables before calling our applications
SET HOMEDRIVE=C:
SET HOMEPATH=\Users\%username%\Windows OR this contains environment path where we kept INI for that environments.

Sometimes this HOMEPATH is different where we keep our application INI files.

But after PB 12.6 (B4091) upgrade, while running application it only fetches C:\Window\WIN.INI file only. due to that it can only connect to one environment. We have multiple environments hosted on single machine (we have different INI files for different environments)

Any pointers ?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Dec 12, 2016 at 06:25 PM
0

You will have to pass the full filename to the ProfileString function. You can use the GetEnvironmentVariable Windows API function to get the homepath.

Function ulong GetEnvironmentVariable(string lpName, Ref string lpBuffer, ulong nSize) Library "kernel32.dll" Alias For "GetEnvironmentVariableW"

lul_Size = 255

ls_Buffer = Space(lul_Size)

lul_rtn = GetEnvironmentVariable(ls_Name, ls_Buffer, lul_Size)

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 15, 2016 at 06:13 AM
0

But it was working till PB12.5 and we didnt get any issue over it.

Earlier it was using Windows file hierarchy to pick correct file. But in PB12.6 its not working. I think PB12.6 changed some windows mechanism or override windows search mechanism to find file.

Your solution is correct. We can fetch environment variable and fetch correct file. We achieved it using ContextService.

We are using ContextService and using that we are fetching environment variable. We also added one more variable in order if later version provide fix then existing code should also work. below are snippets:

ContextKeyword     lcxk_base 

this.GetContextService("Keyword", lcxk_base)
lcxk_base.GetContextKeywords("HOMEDRIVE", ls_home_drive)
lcxk_base.GetContextKeywords("HOMEPATH", ls_home_path)
lcxk_base.GetContextKeywords("PB126_INI", ls_PB126)
IF upperBound (ls_PB126) > 0 THEN 
	ib_PB126_WIN = (ls_PB126[1]='Y')
END IF

IF ib_PB126_WIN THEN is_win_ini_path = ls_home_drive[1] + ls_home_path[1] + "\"

IF ib_PB126_WIN THEN 
	ls_temp = ProfileString(is_win_ini_path+"WIN.INI", ls_proj_name, "INIPATH", "")
ELSE
	ls_temp = ProfileString("WIN.INI", ls_proj_name, "INIPATH", "")
END IF 

We didn't any concrete answer from SAP vendor. :(

Thanks & Regards,

Devang Modi.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 15, 2016 at 02:10 PM
0

Wouldn't it be better to use a .ini file named after your application instead of WIN.INI? WIN.INI is a system file that is only kept around to support 16 bit apps. What happens if Microsoft decides to eliminate it?

Share
10 |10000 characters needed characters left characters exceeded