Jump to content

Ian Branch

Members
  • Content Count

    1352
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Ian Branch

  1. Ian Branch

    caFree & ,Free??

    Hi Team, FWIW, I have gotten rid of all the caFrees in my code. Sticking with the Try.....Finally xxxx.Free end construct. No more issues. Thank you all for your input/feedback. Ian
  2. Ian Branch

    Delete a Registry Key...

    Hi Team, Not sure what is going on here.. Just about to tear what little hair I have out. I am trying to delete a registry key. Win 10, 64bit, D10.3.2. 32bit App. I have the following code.. procedure TMainForm.ClearKey1Click(Sender: TObject); var reg: TRegistry; begin // MessageBeep(MB_ICONINFORMATION); reg := TRegistry.Create(KEY_WRITE); reg.RootKey := HKEY_CURRENT_USER; reg.DeleteKey('DBiW\DBiW\JTGrid'); reg.CloseKey(); // end; It runs without issue/error but does not delete the Key. :-( Is this some 64bit gotcha? I need it to work in 64 & 32 bit environments. Yes, System.Win.Registry is in the Uses list. Thoughts/suggestions appreciated.
  3. Ian Branch

    Delete a Registry Key...

    Hmmmm. Looking into winapi.windows, there is no RegDeleteTree. :-(
  4. Ian Branch

    Delete a Registry Key...

    Hi Remy, Happy to try RegDeleteTree() but I can't get Delphi to recognise it. Obviously I need something in the Uses but I can't find what. I have Winapi.windows in the uses att. Ian.
  5. Ian Branch

    Delete a Registry Key...

    Ahh. Excellent! Thanks Uwe. Works fine now. Regards, Ian
  6. Ian Branch

    Delete a Registry Key...

    Hi Team, D10.4.2, 32 bit App. I am trying to implement this on a Win 10 PC. procedure TMainForm.Button1Click(Sender: TObject); var reg: TRegistry; begin // MessageBeep(MB_ICONINFORMATION); // reg := TRegistry.Create(KEY_WRITE); reg.RootKey := HKEY_CURRENT_USER; // if reg.DeleteKey('Software\MyKey') then showmessage('MyKey registry key deleted.') else begin showmessage('MyKey registry key was NOT deleted.'+#13#10+'Error message is - '+reg.LastErrorMsg); end; // reg.CloseKey(); // end; The key is most assuredly there. I get an access denied error. Maybe not surprising with Win 10 these day. I tried running the App with Admin privileges but same issue. Has anybody got a work around/solution for this please? Regards & TIA, Ian
  7. Ian Branch

    Can't load LivePreview270.bpl

    Ahhh. Thanks Vincent. I don't do FM either so No it is. Cheers. Ian
  8. Ian Branch

    Using Events when creating a component??

    Hi Team, This is a general question I know and should probably be elsewhere, however, I am trying to do it in/with Indy so I would appreciate your indulgence.. I am creating the Indy components on the fly.. ... .... // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(self); IdSMTP1 := TIdSMTP.Create(self); IdMessage1 := TIdMessage.Create(self); // .... ... I have come across routines to update a progress bar in Delphi for Indy. The use the following events... procedure IdSMTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); procedure IdSMTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); procedure IdSMTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); I suspect they would normally be called by the IdSMTP component events, however, per above, I don't have the component physically on the form. How do I link my created IdSMTP1 to these 'events' please? Again, I know this is not an Indy specific question. My apologies. Regards & TIA, Ian
  9. Ian Branch

    Using Events when creating a component??

    Remy, Thank you very much. I had sussed it out to a degree but your code is more refined than mine. Thank you for pointing out TIdCalculateSizeStream. All working as desired now. Regards & Tks again. Ian
  10. Ian Branch

    Using Events when creating a component??

    Hmmm. Given the following snippet.. Codesite.Send('IdMessage1.SaveToStream(TmpStream, False);'); IdMessage1.SaveToStream(TmpStream, False); Codesite.Send('IdSMTP1.Send(IdMessage1);'); IdSMTP1.Send(IdMessage1); I never see the second Codesite message, suggesting that it is falling over at the IdMessage1.SaveToStream.....
  11. Hi Team, D10.4.2, Parnassus Bookmarks v 1.6.2. I thought I was imagining things and now I think it is just a D10.4.2 thing. IIRC, in D10.4.1, Bookmarks would be saved between sessions, so, after closing a project and Delphi, reopening Delphi & the Project would find the bookmarks still present. This doesn't seem to be the case with D10.4.2. Is it just me? Is there a setting I have missed? Anybody else seeing this? I do have GExperts & cnPack installed as well. Regards & TIA, Ian
  12. Ian Branch

    Using Events when creating a component??

    Hi Team, Can someone offer some assistance/advice here? I still can't get the code to work.. procedure TForm1.btnSendClick(Sender: TObject); var Attachmentfile: TIdAttachmentFile; sSendReportTo, sSendReportCC: string; begin // IdSMTP1 := TIdSMTP.Create(nil); // try // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTP1); IdMessage1 := TIdMessage.Create(IdSMTP1); // // IO HANDLER SETTINGS // with IdSSLIOHandlerSocketOpenSSL1 do begin MaxLineAction := maException; SSLOptions.Method := sslvTLSv1; SSLOptions.Mode := sslmUnassigned; SSLOptions.VerifyMode := []; SSLOptions.VerifyDepth := 0; SSLOptions.Mode := sslmClient; end; // // SETTING SMTP COMPONENT DATA // IdSMTP1.Host := 'smtp-server.somewhere.com'; IdSMTP1.Port := 587; IdSMTP1.Username := 'MyName@somewhere.com'; // please change to your gmail address // IdSMTP1.Password := 'Abc123456'; IdSMTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1; IdSMTP1.AuthType := satDefault; IdSMTP1.UseTLS := utUseExplicitTLS; // IdSMTP1.OnWork := IdSMTP1Work; IdSMTP1.OnWorkBegin := IdSMTP1WorkBegin; IdSMTP1.OnWorkEnd := IdSMTP1WorkEnd; // try IdSMTP1.Connect; except on E: Exception do begin MessageDlg('Connection to Mail Server unsuccessful! The following information was returned..: ' + E.Message, mtWarning, [mbOK], 0); Exit; end; end; // // SETTING email MESSAGE DATA // IdMessage1.Clear; // IdMessage1.Recipients.EMailAddresses := 'ToAddress@somewhere.com'; IdMessage1.CCList.EMailAddresses := 'CCAddress@somewhere.com'; // add Attachment to mail // Attachmentfile := TIdAttachmentFile.Create(IdMessage1.MessageParts, 'E:\IndySMTPEmailTest\ReadMe.txt'); // IdMessage1.From.Address := 'myname@somewhere.com'; IdMessage1.Subject := 'Test Email Subject'; IdMessage1.Body.Text := 'Test Email Body'; IdMessage1.Priority := mpHigh; // with TIdText.Create(IdMessage1.MessageParts, nil) do begin Body.Text := '<p style="color: #5e9ca0;">This is a test&nbsp;<strong>message</strong> for <span style="color: #ff0000;"><strong>emailing</strong></span>.</p><h1 style="color: #5e9ca0;">&nbsp;</h1>'; ContentType := 'text/html'; end; // IdMessage1.ContentType := 'multipart/mixed'; // try IdMessage1.SaveToStream(TmpStream, False); IdSMTP1.Send(IdMessage1); ShowMessage('Email sent'); IdSMTP1.Disconnect(); except on e: Exception do begin ShowMessage('Error message is - ' + e.Message); IdSMTP1.Disconnect(); end; end; // Attachmentfile.Free; // finally IdSMTP1.Free; end // end; procedure TForm1.IdSMTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); var nPer: Currency; begin // nPer := 0.0; // try nPer := (AWorkCount / ProgressBar1.Max) * 100; except end; // ProgressBar1.Position := AWorkCount; Label1.Caption := CurrToStrF(nPer, ffFixed, 0) + ' %'; Form1.Update; end; procedure TForm1.IdSMTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); var sStreamSize: string; iValue: Int64; begin Label1.Caption := '0 %'; ProgressBar1.Position := 0; iValue := TmpStream.Size; sStreamSize := iValue.ToString; ShowMessage('Stream Size = ' + sStreamSize); ProgressBar1.Max := TmpStream.Size; Form1.Update; end; procedure TForm1.IdSMTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode); begin ProgressBar1.Position := ProgressBar1.Max; Label1.Caption := '100 %'; Form1.Update; end; It seemingly errors out with "Error message is - Connection Closed Gracefully", there is no apparent 'progress indication and no email is sent. 😞 If I comment out the assignment of the Events and the "IdMessage1.SaveToStream(TmpStream, False);", the email is sent, which indicates the basics are fine. Help! Regards & TIA, Ian
  13. Hi Team, I have 4 buttons evenly spaced across a panel on a form. The form width can be manually expanded at run time. I can set the left and right buttons (1 & 4) using the Anchors. How can I adjust the position of the two middle buttons (2 & 3) programmatically to remain equally spaced between button 1 & 4 if/when the form is expanded? Regards & TIA, Ian
  14. Ian Branch

    Automatic spacing of buttons on a panel??

    Hi haentschman Thank you. Does the job admirably. Took me a little to figure out how to drive it but I got there. Tks again, Ian
  15. Hi Team, Win 10 64bit OS PC, 32GB Ram. m.2 hard drive. I initially tried 10.4.2 but had some issues that are documented elsewhere and I see are the subject of QC entries. So I went back to D10.4.1. I have now come back to D10.4.2. I have seen a few articles about Build/Compile speeds so I thought I would do my own real-world comparison. In 10.4.1 I had Several IDE 'enhancements' loaded and multiple 3rd party libraries, including DDevExtensions & IDEFixPack. I rebuilt my major project group, 18 Apps, according to the build dialog 1821477 lines, 29 Hints, 36 Warnings, 0 Errors. Build time was 1m 27s. I was comfortable with that. In 10.4.2, obviously my old IDEFixPack isn't directly installed but there are multiple components of it now resident in the IDE. The only IDE 'enhancement' I had to reload was Parnassus Bookmarks via GetIt. Without doing anything else aside from updating and re-installing on the 10.4.2 side, I rebuilt my project group again, interestingly, 2041796 lines, 29 Hints, 38 Warnings, 0 Errors. Build time was 1m 19secs, despite the apparent additional lines compiled/built. Subsequent exiting/restarting Delphi and reloading/rebuilding the project group gave me 1m 21secs. Without exiting, just rebuilding, I got 1m 25secs. Interesting. Repeating, I got 1m 20 sec. n.b. The above times include post processing by Eurekalog. All up, I notice no real difference in the Project Group load time and I am happy with the speed. Regards, Ian
  16. Hi Team, Is there a way to retrieve the Delphi version used to build an app, from within the app at run time?? Regards & TIA, Ian
  17. Ian Branch

    Retrieve Delphi version used from within an App?

    Hi Guys, Thank you. I really had expected EMB to have slipped it in there somewhere. Regards, Ian
  18. Ian Branch

    Runtime Error 217 when installing GExperts

    Done. All good now. Tks.
  19. Ian Branch

    Using Events when creating a component??

    Attached is the Stack trace from when the button is clicked.. It 'seems' to be working but to be honest I have no idea what should be happening/seen here.. Certainly nothing is sent.
  20. Ian Branch

    Using Events when creating a component??

    Nope. Red herring. Got the error because I had the Save to stream commented out. :-( Back to the closed gracefully message but nothing sent.
  21. Ian Branch

    Using Events when creating a component??

    I suspect this is the issue.. In the WorkBegin there is, "ProgressBar1.Max := TmpStream.Size." .Max is an Integer, .Size is an Int64. :-( Investigating..
  22. Ian Branch

    Using Events when creating a component??

    Hi Remy, Ahhhh, Tks. As simple as that. I was half expecting it to be more complex. :-) I have added that code.. IdSMTP1.AuthType := satDefault; IdSMTP1.UseTLS := utUseExplicitTLS; // IdSMTP1.OnWork := IdSMTP1Work; IdSMTP1.OnWorkBegin := IdSMTP1WorkBegin; IdSMTP1.OnWorkEnd := IdSMTP1WorkEnd; // Now when run I get the error message.. "Connection closed Gracefully", and nothing sent. :-( If I comment out this line.. try IdSMTP1.Connect(); //IdMessage1.SaveToStream(TmpStream, False); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IdSMTP1.Send(IdMessage1); ShowMessage('Email sent'); and run it, I get an access violation error when achieving 6%. :-( Probably not surprising. This is probably the difference between the original procedure/event definitions, were apparently incompatible, I don't know.. Old... New.. type TForm1 = class(TForm) btnSend: TButton; Button2: TButton; Button3: TButton; ProgressBar1: TProgressBar; Label1: TLabel; procedure btnSendClick(Sender: TObject); procedure Button2Click(Sender: TObject); procedure IdSMTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); procedure IdSMTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); procedure IdSMTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode); The original procedures, shown in my previous email, are a little old, do they need 'revision'? I haven't mentioned - D10.4.1 & Indy 10 as distributed with it. Regards & TIA, Ian
  23. Ian Branch

    Runtime Error 217 when installing GExperts

    Hi Thomas, Errors when building #3451 D2007 & D10.4.1. Regards, Ian
  24. Ian Branch

    Using Events when creating a component??

    Hi Team, For reference/interest, this is what I am trying to get to work.. procedure TForm1.btnSendClick(Sender: TObject); var Attachmentfile: TIdAttachmentFile; sSendReportTo, sSendReportCC: string; begin // IdSMTP1 := TIdSMTP.Create(nil); // try // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTP1); IdMessage1 := TIdMessage.Create(IdSMTP1); // // IO HANDLER SETTINGS // with IdSSLIOHandlerSocketOpenSSL1 do begin MaxLineAction := maException; SSLOptions.Method := sslvTLSv1; SSLOptions.Mode := sslmUnassigned; SSLOptions.VerifyMode := []; SSLOptions.VerifyDepth := 0; end; // // SETTING SMTP COMPONENT DATA // IdSMTP1.Host := 'smtp-mail.outlook.com'; IdSMTP1.Port := 587; IdSMTP1.Username := 'xxxxxx@someplace.com'; // please change to your gmail address // IdSMTP1.Password := 'MyPWD'; IdSMTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1; IdSMTP1.AuthType := satDefault; IdSMTP1.UseTLS := utUseExplicitTLS; // // SETTING email MESSAGE DATA // IdMessage1.Clear; // sSendReportTo := 'yyyyyy@someplace.com'; // Temporary while testing this functionality. sSendReportCC := 'zzzzzz@someplace.com;aaaaaa@someplace.com;bbbbbbb@someplace.com'; // Temporary while testing this functionality. // Process TO: Addressees. while StrTokenCount(sSendReportTo, ';') > 0 do begin // with IdMessage1.Recipients.Add do begin Name := ''; Address := StrToken(sSendReportTo, ';'); end; // end; // Process CC: Addressees. while StrTokenCount(sSendReportCC, ';') > 0 do begin // with IdMessage1.CCList.Add do begin Name := ''; Address := StrToken(sSendReportCC, ';'); end; // end; // add Attachment to mail // Attachmentfile := TIdAttachmentFile.Create(IdMessage1.MessageParts, 'E:\IndySMTPEmailTest\ReadMe.txt'); // IdMessage1.From.Address := 'xxxxxx@someplace.com'; // please change to your gmail address //; IdMessage1.Subject := 'Test Email Subject'; IdMessage1.Body.Text := 'Test Email Body'; IdMessage1.Priority := mpHigh; // with TIdText.Create(IdMessage1.MessageParts, nil) do begin Body.Text := '<p style="color: #5e9ca0;">This is a test&nbsp;<strong>message</strong> for <span style="color: #ff0000;"><strong>emailing</strong></span>.</p><h1 style="color: #5e9ca0;">&nbsp;</h1>'; ContentType := 'text/html'; end; // IdMessage1.ContentType := 'multipart/mixed'; // try IdSMTP1.Connect(); IdMessage1.SaveToStream(TmpStream, False); // TmpStream declared as a form variable. TmpStream: TStream; IdSMTP1.Send(IdMessage1); ShowMessage('Email sent'); IdSMTP1.Disconnect(); except on e: Exception do begin ShowMessage('Error message is - ' + e.Message); IdSMTP1.Disconnect(); end; end; // Attachmentfile.Free; // finally IdSMTP1.Free; end // end; procedure TForm1.IdSMTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); var nPer: Currency; begin // nPer := 0.0; // try nPer := (AWorkCount / ProgressBar1.Max) * 100; except end; // ProgressBar1.Position := AWorkCount; Label1.Caption := CurrToStrF(nPer, ffFixed, 0) + ' %'; Form1.Update; end; procedure TForm1.IdSMTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); begin Label1.Caption := '0 %'; ProgressBar1.Position := 0; ProgressBar1.Max := TmpStream.Size; Form1.Update; end; procedure TForm1.IdSMTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode); begin ProgressBar1.Position := ProgressBar1.Max; Label1.Caption := '100 %'; Form1.Update; end; Regards, Ian
  25. Hi Team, Is it safe/better to do this.. .... .... // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(Self); IdSMTP1 := TIdSMTP.Create(Self); IdMessage1 := TIdMessage.Create(Self); // .... .... ..... // IdSSLIOHandlerSocketOpenSSL1.Free; IdSMTP1.Free; IdMessage1.Free; // ... end; Or this.... .... .... // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil); IdSMTP1 := TIdSMTP.Create(nil); IdMessage1 := TIdMessage.Create(nil); // .... .... ..... // FreeAndNil(IdSSLIOHandlerSocketOpenSSL1); FreeAndNil(IdSMTP1); FreeAndNil(IdMessage1); // ... end; Or something else? Or doesn't it matter? Regards & TIA, Ian
×