Skip to content

Instantly share code, notes, and snippets.

@EifelMono
Last active August 29, 2015 13:58
Show Gist options
  • Save EifelMono/10017417 to your computer and use it in GitHub Desktop.
Save EifelMono/10017417 to your computer and use it in GitHub Desktop.
Call Delphi initialization section
procedure FindInitializationAndCall;
var
nameSpace: string;
foundName: string;
helperType: System.Type;
begin
for helperType in Assembly.GetExecutingAssembly.GetTypes do
begin
nameSpace:= helperType.Namespace;
if Assigned(nameSpace) then
begin
if not nameSpace.Contains('Borland') then
if nameSpace.EndsWith('.Units') then
begin
foundName:= Copy(nameSpace, 1, Length(nameSpace)- Length('.Units'));
if helperType.Name= foundName then
if helperType.IsClass then
helperType.GetMethod(foundName).Invoke(nil, nil);
end;
end;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment