?
Solved

Callind SHGetFolderPath

Posted on 2003-02-21
3
Medium Priority
?
895 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

777 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