xo123
asked on
Create folder
How can I create a folder in Windows
using Powerbuilder script?
For example, create subfolder 'testing' in c:\temp.
using Powerbuilder script?
For example, create subfolder 'testing' in c:\temp.
CreateDirectory( "c:\temp\testing" ) would be sufficient for u
Amit
Amit
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA) Library "KERNEL32" ALIAS FOR CreateDirectoryA
long ll_rc
string ls_path
ls_path = "C:\test\"
ll_rc = CreateDirectory(ls_path, 0)
if ll_rc = 1 then success
long ll_rc
string ls_path
ls_path = "C:\test\"
ll_rc = CreateDirectory(ls_path, 0)
if ll_rc = 1 then success
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, it's PB5 and doesn't support CreateDirectory.
How can I use win API in Powerbuilder?
How to declaure the function?
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA
How can I use win API in Powerbuilder?
How to declaure the function?
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA
Open a window.
Then select "Declare/Global External Functions" or you want to delcare CreateDirectory as a global function or select "Declare/Local Exterbal Functions" menu if you want to use this function only in that window.
Then cut and paste,
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA
Now you can use CreateDirectory function anywhere in that window or anywhere in the code if declared as global external function.
Is yours 16 bit or 32 bit PB? This will not work with 16 bit PB as the declaration is little bit different for 16 bit PB.
HTH
Namasi Navaretnam
Then select "Declare/Global External Functions" or you want to delcare CreateDirectory as a global function or select "Declare/Local Exterbal Functions" menu if you want to use this function only in that window.
Then cut and paste,
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA
Now you can use CreateDirectory function anywhere in that window or anywhere in the code if declared as global external function.
Is yours 16 bit or 32 bit PB? This will not work with 16 bit PB as the declaration is little bit different for 16 bit PB.
HTH
Namasi Navaretnam
ASKER
Great Thanks!
I'm using 32 bit PB.
But how to declare it if it's 16 bit? Is it:
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
I'm using 32 bit PB.
But how to declare it if it's 16 bit? Is it:
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
Yes. For 32 bit,
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
This is an example from Sybase,
CreateDirectoryA( )
This function create a new directory folder under the current directory, which under PowerBuilder would be 'c:\pwrs\pb5i32' if you installed shortnames. The second argument is exclusively used by NT and can be ignored under Win95. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean CreateDirectoryA(ref string pathname, int sa) LIBRARY "Kernel32.dll"
Script:
boolean rtn
string l_dir
l_dir = "API Demo"
rtn = CreateDirectoryA(l_dir, 0)
If rtn then
MessageBox("New Directory Created", "API Demo directory is located under pwrs.")
else
MessageBox("CreateDirector y", "Failed")
end if
CreateDirectoryA( )
This function create a new directory folder under the current directory, which under PowerBuilder would be 'c:\pwrs\pb5i32' if you installed shortnames. The second argument is exclusively used by NT and can be ignored under Win95. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean CreateDirectoryA(ref string pathname, int sa) LIBRARY "Kernel32.dll"
Script:
boolean rtn
string l_dir
l_dir = "API Demo"
rtn = CreateDirectoryA(l_dir, 0)
If rtn then
MessageBox("New Directory Created", "API Demo directory is located under pwrs.")
else
MessageBox("CreateDirector
end if
Creates a directory.
Controls
File system
Syntax
CreateDirectory ( directoryname )
Argument Description
directoryname String for the name of the directory you want to create
Return value
Integer. Returns 1 if the function succeeds and -1 if an error occurs.