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

Calls to WinAPI function "GetCurrentDirectoryA" cause the application to terminate

715 views
Skip to first unread message

Stelios Stylianou

unread,
Oct 26, 2009, 10:57:26 AM10/26/09
to
Hi all,

Using PB703 Build 10213

Tryng to force the dialog box "GetFileOpenName" to open at a specific
folder. I use WIN API Fuctions
"GetCurrentDirectoryA" and "SetCurrentDirectoryA".

Most of the time, the script execute successfully for 2 to 3 times. After
that the aplication termimates - either the next time this process is
triggered or when the window is closed!

Sample script:
ufx_GetCurrentDirectoryA(255, orig_directory/*ref*/)
ufx_SetCurrentDirectoryA(new_path)
GetFileOpenName("Select Picture", s_targer_path/*ref*/, s_filename/*ref*/,
'BMP', 'Bitmap Files (*.bmp)')
/* Process s_filename */
ufx_SetCurrentDirectoryA(orig_directory/)

Any thoughts or comments?

Thank you


Scott Morris

unread,
Oct 26, 2009, 11:24:07 AM10/26/09
to
"Stelios Stylianou" <pios...@piosarota.com.cy> wrote in message
news:4ae5b8d6@forums-1-dub...

MAX_PATH is 260, not 255. But rather than using a hardcoded length, why not
use the proper logic to determine the length of the path? Did you
pre-allocate the space for orig_directory, since GetCurrentDirectory stores
the path in your application's memory? You are also not checking the return
value from these external function calls - are you certain they are
succeeding? Did you know that these same functions were implemented in the
pfc file service?


Roland Smith [TeamSybase]

unread,
Oct 26, 2009, 3:29:41 PM10/26/09
to
The string argument to GetCurrentDirectory must be pre-allocated:

String ls_origpath
Integer li_rtn, li_buflen = 260

ls_origpath = Space(li_buflen)

li_rtn = GetCurrentDirectoryA(li_buflen, ls_origpath)

"Stelios Stylianou" <pios...@piosarota.com.cy> wrote in message
news:4ae5b8d6@forums-1-dub...

0 new messages