Friday, April 12, 2013

[InstallAWare] Delete registry keys created by your application after it was installed

[Reference] http://www.installaware.com/FlashHelp/precedeuninstall.htm
                   http://www.installaware.com/FlashHelp/deleteregistry.htm


To delete registry keys created by your application after it was installed:

    Delete Registry
    This command deletes a value or an entire key from the system registry.
    Root
    Select the root of the delete operation using the drop down menu.
    Key
    Type the name of the key to delete (from).
    Value
    Type the value to delete. Leave empty to delete the default value. If you are deleting the entire key, this field is ignored.
    Delete Entire Key (and subkeys)
    Check this item to delete the entire key, along with any subkeys it contains.
    Delete Value Only
    Check this item to delete the named value only.
     Warning
    • Windows Installer does not provide an easily timed mechanism to delete registry keys. This action will not execute through the Windows Installer engine and is provided as a convenience for the setup developer.
    • We recommend you create all registry keys used by your application as part of your setup. Doing so assures Windows Installer will automatically remove all such keys upon uninstallation.

    Copyright© 1996-2013 InstallAware Software. All rights reserved.

    Tuesday, April 9, 2013

    Draw to TBitmap fail !

    [Reference] http://qc.embarcadero.com/wc/qcmain.aspx?d=43018


    At multi-thread program. The canvas handle of the Bitmap may be freed during the drawing procedure. So, lock the canvas before the drawing operation. And free after the drawing.
    Lock the canvas may reduce the performance. But sometimes you have to do this.

    Canvas->Lock();

    drawing....

    Canvas0->Unlock();

    Friday, April 5, 2013

    如何獲得GetLastError()的文字訊息

    [Reference] http://ascii-iicsa.blogspot.ca/2010/09/getlasterror.html

    int main()
    {
      CString strMsg;

      LPVOID lpMsgBuf;

      FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
                     FORMAT_MESSAGE_FROM_SYSTEM |
                     FORMAT_MESSAGE_IGNORE_INSERTS,
                     NULL,
                     GetLastError(), // 這裡也可以改成你想看的代碼值,例如直接打8L可得"空間不足"
                     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                     (LPTSTR) &lpMsgBuf,
                     0,
                     NULL);

      strMsg.Format( _T("錯誤訊息:%s\n錯誤代碼:0x%x"), 
                     lpMsgBuf,     
                     GetLastError());

      LocalFree(lpMsgBuf); // 記得free掉空間

      return TRUE;
    }


    限制程式只能有一個執行個體?

    [Reference] http://www.programmer-club.com.tw/ShowSameTitleN/cb/10992.html


    在主程式 WinMain() 加入下面程式碼

    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
      HANDLE hMutex;
      // 設定互斥旗標所識別的應用程式名稱
      const char pProgName[]="~!@#$%^project1";
        try {
        // 取得互斥旗標的狀態
          hMutex=OpenMutex(MUTEX_ALL_ACCESS, false, pProgName);
          if ( NULL==hMutex ) {
          // 設定互斥旗標所識別的應用程式名稱
          hMutex=CreateMutex(NULL, true, pProgName);
        }
        else {
          // 系統中已開啟一份應用程式了,因此不啟動本程式
          return 0;
        }

        Application->Initialize();
        Application->CreateForm(__classid(TForm1), &Form1);
        Application->Run();
      }
      catch ( ... ) {
      ...
      }

      // **** 加入部份
      // 釋放互斥旗標
      return ReleaseMutex(hMutex);
    }

    [Qt] 執行檔需要哪些 Dll?

     1. 使用 Qt  的 windeployqt.exe 工具 (在 C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\)。   a. 把執行檔 myProgram.exe 放在某個資料夾。   b. 在檔案總管這個資料夾按 Shift 和滑鼠右鍵,開啟 Po...