cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SetCurrentDirectoryA Doesn't Work

Former Member
0 Likes
1,657

I'm trying to dynamically configure the working directory by calling the external kernel32 SetCurrentDirectoryA function, but no matter what I pass in as the path, it always seems to return false. What would make that happen? I'm using PB 12.6 classic on Win 10 desktop.

View Entire Topic
chris_keating
Product and Topic Expert
Product and Topic Expert
0 Likes

You have to declare the function such that PowerBuilder is treating the string as ANSI, i.e.,

FUNCTION long GetCurrentDirectory( long length , ref string path) LIBRARY "KERNEL32" ALIAS "GetCurrentDirectoryA;ANSI"

Alteratively, you could simply call GetCurrentDirectoryW as that would bypass the conversion.