Get download folder from registry

This forum is for eXpress++ general support.
Post Reply
Message
Author
skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Get download folder from registry

#1 Post by skiman »

Hi,

I want to know the download folder to copy files in the background. A system my customers are using is downloading invoices in the download folder, without any possibility to get them in a predefined folder.

I tried via the registry, but you can't read the values. In the registry itself, there is a note that you have to use a specific function.

This is my code, but it doesn't work. Anyone who has more experience with this? I need to use the function SHGetKnownFolderPath which is in shell32.dll.

Code: Select all

Function fGetPathDownloadfolder()	
***************************************************************************************************
// GUID of download folder: 374DE290-123F-4565-9164-39C4925E467B
// In register: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
// You can't get this value via the register. See the following note in the register when you open the Shell Folders via regedit.
//               "!Do not use this registry key  - Use the SHGetFolderPath or SHGetKnownFolderPath function instead"
// see also: https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath

Local nDll := DllLoad( "SHELL32.DLL" ) 
Local uResult , cPath := space(50)

IF nDll <> 0 
	// Call the API function 
	uResult :=  DllCall( nDll, DLL_STDCALL, ; 
			 'SHGetKnownFolderPath', '374DE290-123F-4565-9164-39C4925E467B', 0,0,@cPath) 
	wtf uResult , cPath		// this gives a negative number as result, cPath remains empty.
	// Release DLL 
	DllUnload( nDll ) 
else
	msgbox("DLL not loaded")
ENDIF 

return nil
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Get download folder from registry

#2 Post by skiman »

In addition,

When the result is positive, there should be some pointer where the path can be found. So cPath won't be filled with a path, but with some pointer.

I don't know how to get the value of that pointer.

Looks as Microsoft made this kind of simple things quite difficult. :(
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Get download folder from registry

#3 Post by Eugene Lutsenko »

In my program: http://lc.kubagro.ru/__AidosALL.txt I use downloading from the hosting and writing to it. To do this, I used to use Boris Borzik's xb2net, and now I do it using standard Alaska 2.0 tools. Downloading is possible both via http and ftp protocols. An example can be found in the function "FUNCTION F6_9()". The downloaded file always appears in the folder where the system is running (not in the download folder).

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Get download folder from registry

#4 Post by skiman »

Hi,

In this case the invoices are downloaded in an external system, where the users have no choice where to download, it is downloaded in the default folder. It is working as a browser, downloads are automatically in the default folder.

To process these invoices with my application, I need to read the download folder. It would be a good solution if I can determine the location of this folder without any user intervention.
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: Get download folder from registry

#5 Post by Auge_Ohr »

hi,

as i can say there is NO "Download Path" in Registry.

you can use Windows "default"

Code: Select all

%USERPROFILE%\Downloads
greetings by OHR
Jimmy

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Get download folder from registry

#6 Post by skiman »

Hi Jimmy,

There IS a download path in the registry. Just search the above GUID with regedit.

With %userprofile%\downloads you aren't sure you have the right folder, a user can place his downloads folder where he wants. As you said, it is the default, which is probably in most cases correct.
Best regards,

Chris.
www.aboservice.be

Post Reply