?
Solved

Callind SHGetFolderPath

Posted on 2003-02-21
3
Medium Priority
?
906 Views
Last Modified: 2013-12-26
Hi,

I need to call SHGetFolderPath from Powerbuilder.  Has anyone done this and if so could you please post sample code?

Thanks!
0
Comment
Question by:rsdiver01
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
buasuwan earned 200 total points
ID: 7998297
you need to declare External Function before using this function.

Function long SHGetFolderPath(long hwnd_owner, long n_folder, long h_token, long dw_reserved, ref string lp_path) Library "shfolder.dll" Alias for "SHGetFolderPathA"


and you need to know each parameter values to be used.

- hwnd_owner   this should be 0, no need to set this value
- n_folder     what do you want to get. here are values list.

CONSTANT long CSIDL_DESKTOP = 0
CONSTANT long CSIDL_INTERNET = 1
CONSTANT long CSIDL_PROGRAMS = 2
CONSTANT long CSIDL_CONTROLS = 3
CONSTANT long CSIDL_PRINTERS = 4
CONSTANT long CSIDL_PERSONAL = 5
CONSTANT long CSIDL_FAVORITES = 6
CONSTANT long CSIDL_STARTUP = 7
CONSTANT long CSIDL_RECENT = 8
CONSTANT long CSIDL_SENDTO = 9
CONSTANT long CSIDL_BITBUCKET = 10
CONSTANT long CSIDL_STARTMENU = 11
CONSTANT long CSIDL_MYDOCUMENTS = 12
CONSTANT long CSIDL_MYMUSIC = 13
CONSTANT long CSIDL_MYVIDEO = 14
CONSTANT long CSIDL_DESKTOPDIRECTORY = 16
CONSTANT long CSIDL_DRIVES = 17
CONSTANT long CSIDL_NETWORK = 18
CONSTANT long CSIDL_NETHOOD = 19
CONSTANT long CSIDL_FONTS = 20
CONSTANT long CSIDL_TEMPLATES = 21
CONSTANT long CSIDL_COMMON_STARTMENU = 22
CONSTANT long CSIDL_COMMON_PROGRAMS = 23
CONSTANT long CSIDL_COMMON_STARTUP = 24
CONSTANT long CSIDL_COMMON_DESKTOPDIRECTORY = 25
CONSTANT long CSIDL_APPDATA = 26
CONSTANT long CSIDL_PRINTHOOD = 27
CONSTANT long CSIDL_LOCAL_APPDATA = 28
CONSTANT long CSIDL_ALTSTARTUP = 29
CONSTANT long CSIDL_COMMON_ALTSTARTUP = 30
CONSTANT long CSIDL_COMMON_FAVORITES = 31
CONSTANT long CSIDL_INTERNET_CACHE = 32
CONSTANT long CSIDL_COOKIES = 33
CONSTANT long CSIDL_HISTORY = 34
CONSTANT long CSIDL_COMMON_APPDATA = 35
CONSTANT long CSIDL_WINDOWS = 36
CONSTANT long CSIDL_SYSTEM = 37
CONSTANT long CSIDL_PROGRAM_FILES = 38
CONSTANT long CSIDL_MYPICTURES = 39
CONSTANT long CSIDL_PROFILE = 40
CONSTANT long CSIDL_SYSTEMX86 = 41
CONSTANT long CSIDL_PROGRAM_FILESX86 = 42
CONSTANT long CSIDL_PROGRAM_FILES_COMMON = 43
CONSTANT long CSIDL_PROGRAM_FILES_COMMONX86 = 44
CONSTANT long CSIDL_COMMON_TEMPLATES = 45
CONSTANT long CSIDL_COMMON_DOCUMENTS = 46
CONSTANT long CSIDL_COMMON_ADMINTOOLS = 47
CONSTANT long CSIDL_ADMINTOOLS = 48
CONSTANT long CSIDL_CONNECTIONS = 49
CONSTANT long CSIDL_COMMON_MUSIC = 53
CONSTANT long CSIDL_COMMON_PICTURES = 54
CONSTANT long CSIDL_COMMON_VIDEO = 55
CONSTANT long CSIDL_RESOURCES = 56
CONSTANT long CSIDL_RESOURCES_LOCALIZED = 57
CONSTANT long CSIDL_COMMON_OEM_LINKS = 58
CONSTANT long CSIDL_CDBURN_AREA = 59
CONSTANT long CSIDL_COMPUTERSNEARME = 61
CONSTANT long CSIDL_FLAG_PER_USER_INIT = 2048
CONSTANT long CSIDL_FLAG_NO_ALIAS = 4096
CONSTANT long CSIDL_FLAG_DONT_VERIFY = 16384
CONSTANT long CSIDL_FLAG_CREATE = 32768
CONSTANT long CSIDL_FLAG_MASK = 65280

- h_token      this should be 0. not used.
- dw_reserved  return current or default value. here 2 values of this

CONSTANT long SHGFP_TYPE_CURRENT = 0 // Return the folder's current path
CONSTANT long SHGFP_TYPE_DEFAULT = 1 // Return the folder's default path

- lp_path      return string to you.


and before call this function. you must allocate space to store data back.

CONSTANT long MAX_LENGTH_PATH = 260

// here is a sample code

string     ls_path
ls_path = space(MAX_LENGTH_PATH)

if SHGetFolderPath(0, CSIDL_PROGRAMS, 0, SHGFP_TYPE_CURRENT, ls_path) = 0 then
    MessageBox("return", ls_path)
end if





0
 

Author Comment

by:rsdiver01
ID: 8008066
Thanks very much for the help!
0
 

Author Comment

by:rsdiver01
ID: 8008088
Thank you SO much for the help!  This will work for me!
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question