Forum > Beginners
Desktop folder
Petrus Vorster:
Hi All
How do I get the Desktop folder in windows?
I need to drop the CSV file on the desktop for the user.
(preferably without the user action or selections.)
I have gone through a lot of searches on the forum, but there are a lot of answers that I currently know nothing off.
Thank you for all your help. It is much appreciated.
-Peter
ASerge:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses WinDirs; procedure TForm1.Button1Click(Sender: TObject);begin Caption := GetWindowsSpecialDir(CSIDL_DESKTOPDIRECTORY);end;
Petrus Vorster:
That's it???
WOW.
Thanks mate.
-Peter
Zvoni:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1;Uses Sysutils;begin writeln(GetUserDir);end.
.... and just append "\Desktop" to it
Note: This goes Kaboom in case of OneDrive (like on my company laptop. My "Desktop" is within OneDrive, so.....)
If it'S OneDrive-Based, you first have to check, if OneDrive is installed (in AppData IIRC), and then build the final Path-String
As a final Sanity-Check use "DirectoryExists" beofre dropping the File on the Desktop
EDIT: AAHA.... Thx Serge.
Didn't know that one.
EDIT2: YAY! Serge's Solution works even with OneDrive-based Folders
eny:
--- Quote from: Zvoni on September 05, 2024, 10:40:19 am ---.... and just append "\Desktop" to it
--- End quote ---
This also does Kaboom for non-English versions of Window$ ;)
Navigation
[0] Message Index
[#] Next page