Page 2 of 2

Re: Unable to detect resource leak in X64 VCL app

Posted: Sat Dec 08, 2018 5:19 am
by q675318
my fix code
MainDir is setup root dir

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  MyReg: TRegistry;
begin
  MyReg := TRegistry.Create(KEY_WRITE or KEY_READ or KEY_WOW64_64KEY);
  MyReg.RootKey := HKEY_LOCAL_MACHINE;

  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\madshi\madCollection', True) then
  begin
    MyReg.WriteString('',MainDir2);
    MyReg.WriteBinaryData('key',pbyte(keyMem.Memory)^,keyMem.Size);
  end;
  MyReg.CloseKey;

  if MyReg.OpenKey('SOFTWARE\madshi\madCollection', True) then
  begin
    MyReg.WriteString('',MainDir2);
    MyReg.WriteBinaryData('key',pbyte(keyMem.Memory)^,keyMem.Size);
  end;
  MyReg.CloseKey;

  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptBugReport\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madExceptViewer.exe');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptBugReport\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madExceptViewer.exe');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptBugReport\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madExceptViewer.exe" "%1"');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptBugReport\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madExceptViewer.exe" "%1"');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptPlugin\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madPluginMan.exe');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptPlugin\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madPluginMan.exe');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptPlugin\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madPluginMan.exe" "%1"');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptPlugin\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madPluginMan.exe" "%1"');
  end;
  MyReg.CloseKey;
  MyReg.Free;
end;

Re: Unable to detect resource leak in X64 VCL app

Posted: Sat Dec 08, 2018 11:10 am
by madshi
Thanks for finding the cause of the problem q675318!

The reason it still worked on my PC is that madExcept.pas has a special case for my development PC, where madExcept32/64.dll are compiled to "c:\sources\madshi".

Anyway, should be fixed in this build:

http://madshi.net/madCollectionBeta.exe (installer 2.8.8.2)

Re: Unable to detect resource leak in X64 VCL app

Posted: Sat Dec 08, 2018 11:25 am
by spanfkyous
q675318 wrote:my fix code
MainDir is setup root dir

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  MyReg: TRegistry;
begin
  MyReg := TRegistry.Create(KEY_WRITE or KEY_READ or KEY_WOW64_64KEY);
  MyReg.RootKey := HKEY_LOCAL_MACHINE;

  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\madshi\madCollection', True) then
  begin
    MyReg.WriteString('',MainDir2);
    MyReg.WriteBinaryData('key',pbyte(keyMem.Memory)^,keyMem.Size);
  end;
  MyReg.CloseKey;

  if MyReg.OpenKey('SOFTWARE\madshi\madCollection', True) then
  begin
    MyReg.WriteString('',MainDir2);
    MyReg.WriteBinaryData('key',pbyte(keyMem.Memory)^,keyMem.Size);
  end;
  MyReg.CloseKey;

  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptBugReport\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madExceptViewer.exe');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptBugReport\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madExceptViewer.exe');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptBugReport\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madExceptViewer.exe" "%1"');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptBugReport\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madExceptViewer.exe" "%1"');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptPlugin\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madPluginMan.exe');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptPlugin\DefaultIcon', True) then
  begin
    MyReg.WriteString('',MainDir+'madExcept\Tools\madPluginMan.exe');
  end;
  MyReg.CloseKey;
  //-------------------------------------------------------
  if MyReg.OpenKey('SOFTWARE\Wow6432Node\Classes\madExceptPlugin\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madPluginMan.exe" "%1"');
  end;
  MyReg.CloseKey;
  if MyReg.OpenKey('SOFTWARE\Classes\madExceptPlugin\shell\open\command', True) then
  begin
    MyReg.WriteString('','"'+MainDir+'madExcept\Tools\madPluginMan.exe" "%1"');
  end;
  MyReg.CloseKey;
  MyReg.Free;
end;

Good Job