Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SHGetFolderPath in PB 11.5.1

113 views
Skip to first unread message

Gordon

unread,
Jul 23, 2009, 1:22:54 PM7/23/09
to
I'm a newbie to Powerbuilder. We have some 10.5 applications we are
migrating to 11.5 and I need to correct a design flaw in the program
that stores database connection parameters in the root folder of the
C: drive. (No idea why that decision was made when the programs were
designed.) I'm used the SHGetFolderPath function to get the path to
the Documents and Settings\<user>\Application Data folder in several
other languages, but am having problems in PowerBuilder. Here's what
I have...

Global Function
FUNCTION ulong SHGetFolderPath (ulong hWndOwner, int nFolder, long
hToken, ulong dwFlags, ref string pszpath) LIBRARY "shell32.dll"

and in the routine

CONSTANT ulong SHGFP_TYPE_CURRENT = 0 // Return the folder's current
path
CONSTANT int CSIDL_APPDATA = 26
CONSTANT long MAX_LENGTH_PATH = 255
int PathResult

string ls_path
ls_path = space(MAX_LENGTH_PATH)

if SHGetFolderPath(0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT, ls_path)
<> 0 then
MessageBox("Application Error", "Failed to return user application
folder.")
Else
ls_path = ls_path + “\DistApps”
if DirectoryExists( ls_path ) then
else
CreateDirectory( ls_path )
end If
end if

It compiles OK, but when I run the program, I get:
Error: Bad runtime function reference at line 40 in open event of
object hr_report.

The SHGetFolderPath function call is line 40.

Any help would be appreciated.

Jerry Siegel [TeamSybase]

unread,
Jul 23, 2009, 2:14:26 PM7/23/09
to
Says here http://msdn.microsoft.com/en-us/library/bb762181%28VS.85%29.aspx
that function has been deprecated. You may need to try the A or more likely
W (Unicode) version.

--
Report Bugs: http://case-express.sybase.com/cx/welcome.do
Product Enhancement Requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement


"Gordon" <gordon....@citi.com> wrote in message
news:6aaff8b4-0e17-4ed8...@c14g2000yqm.googlegroups.com...

Roland Smith [TeamSybase]

unread,
Jul 23, 2009, 3:33:19 PM7/23/09
to
Gordon,

This example on my website uses SHGetFolderPathW. The zipfile contains an
example for PB8 and PB10. You will want to use the PB10 one and convert it
to 11.5.

http://www.topwizprogramming.com/freecode_filesys.html

Roland

"Gordon" <gordon....@citi.com> wrote in message
news:6aaff8b4-0e17-4ed8...@c14g2000yqm.googlegroups.com...

Gordon

unread,
Jul 24, 2009, 9:48:36 AM7/24/09
to
On Jul 23, 3:33 pm, "Roland Smith [TeamSybase]"

<rsmith_at_trusthss_dot_com> wrote:
> Gordon,
>
> This example on my website uses SHGetFolderPathW. The zipfile contains an
> example for PB8 and PB10. You will want to use the PB10 one and convert it
> to 11.5.
>
> http://www.topwizprogramming.com/freecode_filesys.html

Thanks Roland, that was exactly what I needed.

Gordon

unread,
Jul 24, 2009, 9:50:47 AM7/24/09
to
On Jul 23, 2:14 pm, "Jerry Siegel [TeamSybase]"
<jNOsSPAMsiegel@yahoo!.com> wrote:
> Says herehttp://msdn.microsoft.com/en-us/library/bb762181%28VS.85%29.aspx

> that function has been deprecated. You may need to try the A or more likely
> W (Unicode) version.

Thanks Jerry, that's news to me. But we are implementing on Windows
XP so I can't use the SHGetKnownFolderPath function.

0 new messages