Discussion:
How to get full project path ?
(too old to reply)
AlexB
2008-05-04 05:28:43 UTC
Permalink
Hi all.

Q1. I like to save a file in the project directory. How I can get the
full project path with OTA ?

Q2. What path is suitable for storing an IDE-related (not
project-related) files of the custom plugin ? How to get the full path
of that directory with OTA ?

TIA
--
Alex
Lex Y. Li
2008-05-04 11:39:21 UTC
Permalink
Post by AlexB
Q1. I like to save a file in the project directory. How I can get the
full project path with OTA ?
You can get full path of the project file from IOTAProject.FileName.
Then you can save files to the same folder of this project file.
Post by AlexB
Q2. What path is suitable for storing an IDE-related (not
project-related) files of the custom plugin ? How to get the full path
of that directory with OTA ?
According to Vista rules, you should save files to a few recommended
places. Then you don't need any OTA functions. Use Win32 API is enough.
AlexB
2008-05-04 12:10:14 UTC
Permalink
Post by Lex Y. Li
Post by AlexB
Q1. I like to save a file in the project directory. How I can get
the full project path with OTA ?
You can get full path of the project file from IOTAProject.FileName.
Then you can save files to the same folder of this project file.
There is no such function/property in IOTAProject (at least I can't
find it in ToolsAPI.pas for RAD2007 and it's the reason why I'm asking
about it). Could you point out the exact interface ?
Post by Lex Y. Li
Post by AlexB
Q2. What path is suitable for storing an IDE-related (not
project-related) files of the custom plugin ? How to get the full
path of that directory with OTA ?
According to Vista rules, you should save files to a few recommended
places. Then you don't need any OTA functions. Use Win32 API is enough.
It's true but I mainly ask about Studio IDE's special rules/conventions
(if any).
--
Alex
Dennis Passmore
2008-05-04 21:01:49 UTC
Permalink
uses
Windows, Sysutils, ToolsAPI;

function GetProjectGroup: IOTAProjectGroup;
var
IModuleServices: IOTAModuleServices;
IModule: IOTAModule;
i: Integer;
begin
Assert(Assigned(BorlandIDEServices));

IModuleServices := BorlandIDEServices as IOTAModuleServices;
Assert(Assigned(IModuleServices));

Result := nil;
for i := 0 to IModuleServices.ModuleCount - 1 do
begin
IModule := IModuleServices.Modules[i];
if IModule.QueryInterface(IOTAProjectGroup, Result) = S_OK then
Break;
end;
end;

function GetCurrentProjectName: string;
var
Project: IOTAProject;
ProjectGroup: IOTAProjectGroup;
begin
Result := '';
ProjectGroup := GetProjectGroup;
if Assigned(ProjectGroup) then
begin
Project := ProjectGroup.ActiveProject;
if Assigned(Project) then
Result := Project.FileName;
end;
end;
AlexB
2008-05-05 02:54:21 UTC
Permalink
Post by Dennis Passmore
function GetCurrentProjectName: string;
Looks slightly tricky, very helpful :-)
Thank you Dennis.
--
Alex
AlexB
2008-05-05 05:14:20 UTC
Permalink
Post by AlexB
Post by Lex Y. Li
You can get full path of the project file from IOTAProject.FileName.
Could you point out the exact interface ?
Oh, I see now: IOTAProject is descendant of IOTAModule which contains
FileName property.

Thanks.
--
Alex
Loading...