Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using GETFILE and starting at 'My Documents'
Message
From
11/04/2008 20:59:10
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01309856
Message ID:
01310130
Views:
29
Hi Sergey!
Thanks for the example.
I've tried your code but I discovered 2 problems.
1. In different languages the 'My Documents' folder
changes its name. In Portuguese, my language, is
'Os Meus Documentos'.
2. Another problem is that sometimes the user change
the location of 'My Documents' folder. I've change
it to another partition - D:\Os Meus Documentos
So, the code you sent me 'stares' at the user folder
inside 'Documents and Settings'.
Then I remembered that Windows stores the location of
special folders in the registry. So I've used Windows
Script Host to read the key/value where that information
is located. We can use the same procedure to locate
folders like 'My Music', 'My Pictures', 'Favorites', etc.
Here is the code:
WSHShell = CreateObject("WScript.Shell")

lcMyDocuments = WSHShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal")

CHDIR (lcMyDocuments)
lcFile = GETFILE()
It worked like a charm.

>>Hi.
>>I'm using GETFILE to open a file but I
>>want to select the 'My Documents' folder
>>as starting folder.
>>I think that I need to change the current
>>directory to 'My Documents' using CHDIR
>>and then invoke the GETFILE. Question:
>>1) How can I change to 'My Documents' if
>> the path depends on the user logged-in?
>
>DECLARE INTEGER SHGetFolderPath IN SHFOLDER.DLL ;
>   INTEGER hwndOwner, ;
>   INTEGER nFolder, ;
>   INTEGER hToken, ;
>   INTEGER dwFlags, ;
>   STRING @ pszPath
>lcPath = REPL(CHR(0),261)
>= SHGetFolderPath(0,0x28,0,0,@lcPath)
>lcMyDocuments = LEFT(lcPath,AT(CHR(0),lcPath)-1)
>CD (lcMyDocuments)
>lcFile = GETFILE()
>
>
>
>>or
>>2) Is there another way to do that?
>
>You can use Open File from Windows Common Dialog Controls that have more options. Check Customize the open dialog box in VFP Solutions
***
TONY Nascimento
*****************

"Your mind is like a parachute. It only works if it is open" - Anthony J. D'Angelo

"The desire to know is natural to good men" - Leonardo da Vinci
Previous
Reply
Map
View

Click here to load this message in the networking platform