uses
ToolsAPI;
function GetCurrentProject: IOTAProject;
var
Services: IOTAModuleServices;
Module: IOTAModule;
Project: IOTAProject;
ProjectGroup: IOTAProjectGroup;
MultipleProjects: Boolean;
I: Integer;
begin
Result := nil;
MultipleProjects := False;
Services := BorlandIDEServices as IOTAModuleServices;
for I := 0 to Services.ModuleCount - 1 do
begin
Module := Services.Modules;
if Module.QueryInterface(IOTAProjectGroup, ProjectGroup) = S_OK then
begin
Result := ProjectGroup.ActiveProject;
Exit;
end
else if Module.QueryInterface(IOTAProject, Project) = S_OK then
begin
if Result = nil then
// Found the first project, so save it
Result := Project
else
MultipleProjects := True;
// It doesn't look good, but keep searching for a project group
end;
end;
if MultipleProjects then
Result := nil;
end;
MessageBox(0, PChar(GetCurrentProject().FileName), '', 0);
你就看到当前工程的全路径文件名了.
ExtractFilePath分解出文件路径