Forum > Operating Systems

[solved] GetDesktopPath

(1/2) > >>

Handoko:
Can anyone help me test this code on Linuxes and Windows? I tested on Ubuntu Mate and WinXP, it works but I want to make sure it 'really' works. Or maybe you have better suggestion.


--- 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";}};} ---function GetDesktopPath: string;var  S: string;begin{$ifdef WINDOWS}  S := GetEnvironmentVariable('HOMEDRIVE') + GetEnvironmentVariable('HOMEPATH');{$endif}{$ifdef LINUX}  S := GetEnvironmentVariable('HOME');{$endif}  Result := S + DirectorySeparator + 'Desktop' + DirectorySeparator;end;
Note:
SysUtils unit is required.

ASerge:

--- Quote from: Handoko on October 20, 2020, 08:00:14 pm ---Can anyone help me test this code on Linuxes and Windows? I tested on Ubuntu Mate and WinXP, it works but I want to make sure it 'really' works. Or maybe you have better suggestion.

--- End quote ---
Windows 7 - work. But it is more correct to use WinDirs.GetWindowsSpecialDir(CSIDL_DESKTOPDIRECTORY, False);

Lulu:
Tested on win10: both Handoko and ASerge code work

kapibara:
Tested OK with XUbuntu 20.04.

trev:
Change:


--- 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";}};} ---{$ifdef LINUX}
To:


--- 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";}};} ---{$ifdef UNIX}
And it will now also work in macOS and FreeBSD (tested :-)

Navigation

[0] Message Index

[#] Next page

Go to full version