Jump to content

THANHNM

Members
  • Content Count

    3
  • Joined

  • Last visited

Posts posted by THANHNM


  1. 1 hour ago, rvk said:

    If your application is 32bit you also should use the 32 bit dll's. Not the x64 bit ones.

    Putting them in your exe directory and not using IdOpenSSLSetLibPath should also work.

     

    Oh tks, it's working now!
    I thought the bit version is about the OS, didn't read the document carefully


  2. So Is that mean I can't simply call RegisterServiceCtrlHandlerEx from Delphi? 
    And does windows 10 fast-startup throws those events too? Because I need to stop my service when Hibernate/Shutdown and resume it on after Waked-up/Startup. 

    I'm trying this:

    function MySvcHandlerFunctionEx(dwControl, dwEventType: DWORD; lpEventData, lpContext: Pointer): DWORD; stdcall;
    var _lpContext: PMyDefine;
        F: TextFile;
    begin
      AssignFile(F, 'C:\Test.txt');
      try
        if FileExists('C:\Test.txt') then
          Append(F)
        else
          Rewrite(F);
        WriteLn(F, 'Got Data: ' + inttostr(dwControl));
    
        if dwEventType = WM_POWERBROADCAST then
        begin
          _lpContext := PMyDefine(lpContext);
    
          WriteLn(F, 'MySvcHandler: ' + IntToStr(dwControl) + ' - ' + _lpContext.s);
        end;
      finally
        Result := NO_ERROR;
        CloseFile(F);
      end;
    end;
    
    procedure TCMCRTEngine.ServiceStart(Sender: TService; var Started: Boolean);
    var lpContext: PMyDefine;
    begin
      ...
      New(lpContext);
      lpContext.s := 'My_Test_Svc';
      SvcHandler := RegisterServiceCtrlHandlerEx(PWideChar('MyService'), @MySvcHandlerFunctionEx, lpContext);
    end;

    And I didn't receive anything yet

×