Jump to content

Stéphane Wierzbicki

Members
  • Content Count

    232
  • Joined

  • Last visited

Posts posted by Stéphane Wierzbicki


  1. I'm also facing issues with RDP and Delphi 12 (actionbar menus are messy). No problem at all with Delphi 11.

     

    Found this workaround.

     

    program xxxxx;
    
    uses
      Vcl.Forms,
      WinAPI.Windows,
      ....;
    
    {$R *.res}
    begin
      Application.SingleBufferingInRemoteSessions := GetSystemMetrics(SM_REMOTESESSION) = 0;
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.Title := 'xxxxxxxxxxxxxxxx';
      Application.CreateForm(Tformxxxx, formxxxx);
      Application.Run;
    end.


     

     


  2. I've asked ChatGPT. He proposed this:

     

    To authenticate with Microsoft 365 and send emails through Exchange Online, you can use the Microsoft Graph API to obtain an access token, and then include that access token in the HTTP headers when sending the email. Here's an example Delphi code that shows how to do this:

     

    delphi

    Copy code

     

    uses

      System.Net.URLClient, System.Net.HttpClient, System.Net.HttpClientComponent;

     

    procedure SendEmail;

    var

      AuthToken: string;

      Http: TNetHTTPClient;

      Request: TNetHTTPRequest;

      Response: IHTTPResponse;

      Body: TStringStream;

    begin

      // First, obtain an access token using the Microsoft Graph API.

      Http := TNetHTTPClient.Create(nil);

      try

        Body := TStringStream.Create('grant_type=client_credentials&client_id=<your_client_id>&client_secret=<your_client_secret>&scope=https://graph.microsoft.com/.default');

        try

          Response := Http.Post('https://login.microsoftonline.com/<your_tenant_id>/oauth2/v2.0/token', Body, nil);

          try

            if Response.StatusCode = 200 then

            begin

              AuthToken := TJSONObject.ParseJSONValue(Response.ContentAsString).GetValue<string>('access_token');

            end

            else

            begin

              // Handle error.

              Exit;

            end;

          finally

            Response := nil;

          end;

        finally

          Body.Free;

        end;

      finally

        Http.Free;

      end;

     

      // Now, send the email using the access token.

      Http := TNetHTTPClient.Create(nil);

      try

        Request := TNetHTTPRequest.Create(nil);

        try

          Request.Method := TNetHTTPRequest.TMethod.rmPOST;

          Request.URL := 'https://graph.microsoft.com/v1.0/me/sendMail';

          Request.ContentType := 'application/json';

          Request.CustomHeaders['Authorization'] := 'Bearer ' + AuthToken;

          Request.Source := TStringStream.Create('{ ' +

            '"message": {' +

              '"subject": "Test email",' +

              '"body": {' +

                '"contentType": "Text",' +

                '"content": "This is a test email."' +

              '},' +

              '"toRecipients": [{' +

                '"emailAddress": {' +

                  '"address": "<recipient_email_address>"' +

                '}' +

              '}]' +

            '},' +

            '"saveToSentItems": "true"' +

          '}', TEncoding.UTF8);

          Response := Http.Execute(Request);

          try

            if Response.StatusCode <> 202 then

            begin

              // Handle error.

            end;

          finally

            Response := nil;

          end;

        finally

          Request.Free;

        end;

      finally

        Http.Free;

      end;

    end;

     

    Replace <your_client_id>, <your_client_secret>, <your_tenant_id>, and <recipient_email_address> with your own values.

     

    Note that you'll need to register an application in the Azure Portal and grant it the appropriate permissions to use the Microsoft Graph API

    • Like 1

  3. 6 hours ago, Ian Branch said:

    Hi Team,

    Does anybody know of an English version of GLibWMI?

    I'm afraid my French, or whatever language it is, is not all that good.  i.e. non existant.

    Also, I don't think English Users would appreciate non-english prompts. 😉

    Alternatively, is there another Library that provides similar functionality?

    I'm really only after the ability to stop/start windows services.

     

    Regards & TIA,

    Ian

    Hi Ian,

     

    I guess it is Spanish, definitely not French.

     

    Why don't you get in touch with the developer and help him translating in English?


  4. Hello,

     

    I have a very odd issue with Delphi 11.2 (French Windows 11 22H2).

    I'm no more able to compile/build any Win64 project after compiling a Win64 "Python4Delphi" project (python version installed: 3.10.8)

     

    Here is the message I'm getting:

    Quote

     

    [MSBuild Error] The "BRCC32" task failed unexpectedly.
    System.IO.IOException: Le texte du message associé au numéro 0x%1 est introuvable dans le fichier de messages pour %2.

       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
       at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
       at Borland.Build.Tasks.Common.CommandLineTask.CreateTempFileIfNecessary(ITaskItem basedOn)
       at Borland.Build.Tasks.Common.CommandLineTask.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)

     

     

    I'm able to compile and run the project after restarting the IDE, but cannot build any other Win64 project (need to restart the IDE).

     

    This is really bizarre.

     


  5. Hello,

     

    Just to let you know.

    Each time I install a Delphi Update, I'm getting this errorimage.png.fa7b0885107353d443e4b3fff1a38e82.png:

     

     

    Steps:

    Download new Delphi web installer

    Run Delphi web installer

    Installer ask uninstalling previous delphi version. Keep registry settings and proceed

    Installer uninstall delphi

    Installer display install option (which platform to install + add. options"

    When installer is over, you are invited to click the "Begin work" (or something similar)

    Installer is closing and running Delphi IDE

    Act: Exception is displayed

     

    Thanks


  6. Just now, PeterPanettone said:

    There must be some other failure because the IDE RESTART failed on other occasions before too after installing something from GetIt which required a restart. So it's the IDE RESTART procedure that fails under specific conditions.

    FWIW I haven't installed Bookmarks nor navigator plugins right now. I'll next week. 

     

    If the same issue happens I will try to uninstall all experts, start Delphi and reinstall Bookmarks and navigator through Getit to see how it will behave.

     

    I'll keep informed.

×