I am trying to get the temporary windows folder name. I declared local
external function as follows:
FUNCTION ulong GetTempPathA (long nBufferLength, ref string lpBuffer )
LIBRARY "KERNEL32.DLL"
Then have the following code in the clicked event of a button on the window:
constant long lcl_maxpath = 260
string ls_tempdir
ulong lul_retval
ls_tempdir = Fill('0', lcl_maxpath)
lul_retval = parent.GetTempPatha(lcl_maxpath, ls_tempdir)
IF lul_retval > 0 THEN
Messagebox("Temp path", ls_tempdir)
END IF
The above code displays chinese letters only instead of the path name!
I am using Windows Vista Business and PowerBuilder 11.5
Does anybody know the solution to this problem? Am I calling the right
function?
TIA,
Somnath
FUNCTION Long GetTempPath(Long nBufferLength, REF String lpBuffer) LIBRARY
"KERNEL32.DLL" ALIAS FOR "GetTempPathA;Ansi"
and then:
String ls_temppath
ls_temppath = Space(255)
GetTempPath(255,ls_temppath)
It's working in PB 11.5 under Windows Vista Business
Best regards!
Krzysztof Korolonek
--
Dave Hauze
"Krzysztof Korolonek" <krzysztof...@fibermedia.pl> wrote in message
news:4a0976b1@forums-1-dub...
Use the unicode version of the function "GetTempPathW(long nBufferLength,
ref string lpBuffer)"
Or you can add the Alias statement after the function declaration, like:
GetTempPathW(long nBufferLength, ref string lpBuffer) ALIAS FOR
"GetTempPathA;ANSI"
--
Dave Hauze
"Somnath" <junka...@somedomain.com> wrote in message
news:4a0971b8@forums-1-dub...
"Dave Hauze" <david...@steeldynamics.com> wrote in message
news:4a097782$1@forums-1-dub...
You don't have to use an external function.
Instead you can use GetContextService function to get the
environment variable.
Try this.
------------------------------------------------------
ContextKeyword lcxk_base
String ls_values[]
GetContextService("ContextKeyword", lcxk_base)
lcxk_base.GetContextKeywords("TEMP", ls_values)
MessageBox("TEMP", "TEMP is : " + ls_values[1])
------------------------------------------------------
"Krzysztof Korolonek" <krzysztof...@fibermedia.pl> wrote in message
news:4a0976b1@forums-1-dub...
--
Dave Hauze
"Roland Smith [TeamSybase]" <rsmith_at_trusthss_dot_com> wrote in message
news:4a09a437$1@forums-1-dub...
I used both methods but get short names anyone know how I can get long
names?
Best Regards,
Bob
Function Long GetLongPathName(String lpShortPath, REF String
lpLongPath, Long cBuffer) Library "kernel32.dll" ALIAS FOR
"GetLongPathNameW"
-----------------------------------
My Web 2.0 Stuff
Blog: http://bruce.pbdjmagazine.com/
Facebook: http://www.facebook.com/people/Bruce-Armstrong/1600223798
Fotki: http://public.fotki.com/brucearmstrong/
LinkedIn: http://www.linkedin.com/in/bruceaarmstrong
Twitter: http://twitter.com/bruce_armstrong
YouTube: http://www.youtube.com/user/brucearmstrong