Reputation: 17
Okay, first question; should be reasonably simple to answer, but as a somewhat beginner programmer I'm unsure of the solution:
C:\Folder\Folder2
C:\Folder\Folder3
C:\Folder\Folder4
So, the first query is how would I achieve that? (I'm not fussed about whether it's in console mode or in a form, though I'd imagine using a ListBox in a form would be more appropriate?)
Secondly, I'd like to know if I could do the above with my %AppData% folder -
C:\Users\...\AppData\Skype
C:\Users\...\AppData\Firefox
Thirdly, and finally - I seem to recall I -would- be able to do this sort of thing easily in Python, so is it viable at all to use Delphi coding to call a Python script (The software I'm using normally uses Delphi scripts, so I'm having to teach it to myself as I use it (sort-of dropping myself at the deep end, I know) - but could I write some kind of procedure in Delphi, for example by modifying the startup script for the software, and get it to call a script made in Python, or are they totally incompatible?
Again, if it's possible, I'd appreciate being told how (because I've no clue!)
Thanks for reading (and contributing, if you do!)
Upvotes: 1
Views: 203
Reputation: 613352
There's nothing to be gained from shelling out to Python here. Delphi can do all you need easily enough, you just have to work out how to make the magic incantations.
It looks like you are just calling SHGetSpecialFolderPath
incorrectly. Here is how I do it:
type
TWin32PathBuffer = array [0..Windows.MAX_PATH-1] of char;
function GetSpecialFolderPath(const CSIDL: Integer): string;
var
Buffer: TWin32PathBuffer;
begin
Win32Check(SHGetSpecialFolderPath(0, @Buffer[0], CSIDL, False));
Result := Buffer;
end;
The final part of the jigsaw is how to enumerate sub-directories. In modern Delphi you can use TDirectory.GetDirectories
from the IOUtils
unit. If you don't have a modern Delphi then you have to call FindFirst
, FindNext
etc. There are at least a gazillion examples of this code to be found on the web. This one appears to do what you need: http://delphi.about.com/od/delphitips2008/qt/subdirectories.htm
Upvotes: 1