Launch the dll at install time

Hi developers,

How can i launch the dll at install time. Now i know there is a parameter in .inf file [CESetupDLL=setup_DLL]  where i give the dll file name . But how do i invoke the entry point function in the dll.

Regards,

Parag


Answer this question

Launch the dll at install time

  • acribb

    There is a sample called SetupDLL that is part of the Windows Mobile 5.0 SDK. (I believe it was there for older versions of the SDK as well). You might want to take a look at it.

    This is what the entry point should look like for your DLL:


    BOOL APIENTRY DllMain(
       HANDLE hModule, 
       DWORD ul_reason_for_call, 
       LPVOID lpReserved)
    {
       switch (ul_reason_for_call)
       {
          
    case DLL_PROCESS_ATTACH:
          
    case DLL_THREAD_ATTACH:
          
    case DLL_THREAD_DETACH:
          
    case DLL_PROCESS_DETACH:
             g_hinstModule = (HINSTANCE)hModule;
             
    break;
       }
       
    return TRUE;
    }

    SETUP_API codeINSTALL_INIT Install_Init(
       HWND hwndParent,
       BOOL fFirstCall,
       
    BOOL fPreviouslyInstalled,
       LPCTSTR pszInstallDir)
    {
       
    // ... Do work the first time.
    }

     



    I have pasted what the signature for Install_Init should look like. Take a look at http://msdn.microsoft.com/library/default.asp url=/library/en-us/apippc/html/ppc_ce_setup_install_init.asp

    Good luck!

    Luis Cabrera
    SDE - Microsoft.
    - This posting is "AS IS" and cofers no rights or privileges -



  • BillWert - MSFT

    Hello Developers,

    Thanks luis for the reply . I am giveing below a snippet of code , I guess something is wrong with it which I can't figure out . I have a dialog that should pop up in the dll at install time. Can I debug the dll , if yes how

    // This is the CPP
    codeINSTALL_INIT Install_Init( HWND hwndParent,
                                              BOOL fFirstCall,
                                              BOOL fPreviouslyInstalled,
                                              LPCTSTR pszInstallDir)
    {

    CreateDialog (g_hInst,                     
                       MAKEINTRESOURCE (IDD_DIALOG), 
                       hwndMain,  
                       (DLGPROC)DialogProc); 
      if(commandStatus)
      {
       return codeINSTALL_INIT_CONTINUE;
      }
      else
      {
        return codeINSTALL_INIT_CANCEL;
      }

    }


    BOOL CALLBACK DialogProc ( HWND hwndDlg,   // Handle to the dialog box.
             UINT uMsg,      // Message.
             WPARAM wParam,  // First message parameter.
             LPARAM lParam, // Second message parameter.
             HWND hwndText
            )
    {
      SHMENUBARINFO MenuBar;

      switch(uMsg)
      {
        case WM_INITDIALOG:
      {
       ZeroMemory(&MenuBar, sizeof(MenuBar));
       MenuBar.cbSize = sizeof(MenuBar);
       MenuBar.hwndParent = hwndDlg;
       MenuBar.nToolBarId = IDR_SOFTKEYS_MENU;
       MenuBar.hInstRes = g_hInst;

       if (SHCreateMenuBar(&MenuBar))
       {
        TCHAR Fbuf[256];
        hwndText = GetDlgItem(hwndDlg, IDC_CTEXT);
        wcscat( Fbuf, TEXT("*** it works man !!!"));
        SendMessage(hwndText, LB_INSERTSTRING,(LPARAM) Fbuf,0);
        return TRUE;
       }
      }
        case WM_COMMAND:
          switch (LOWORD(wParam))
          {

             case IDS_MENUITEM_OK:
          {
          commandStatus = true;
          EndDialog(hwndDlg, 0);
          break;
          }
       case IDS_MENUITEM_CANCEL:
          {
          commandStatus = false;
          EndDialog(hwndDlg, 0);
          break;
          }

      return TRUE;
          }

      }
      return FALSE;
    }


    // Here is the inf file

    [Version]
    Signature = "$Windows NT$"       ; Required as-is
    Provider = "Device Cap"               ; Maximum of 30 characters, full app name will be "<Provider> <AppName>"
    CESignature = "$Windows CE$"     ; Required as-is

    [CEStrings]
    AppName = "DeviceID_CellID" ; Maximum of 40 characters, full app name will be "<Provider> <AppName>"
    InstallDir = %CE1%\DeviceID_CellID   ; Program Files\DeviceID_CellID

    [CEDevice.ARM]
    ProcessorType = 2577

    [DefaultInstall]
    CopyFiles = Files
    CEShortcuts = Shortcuts

    [DefaultInstall.SA]
    CopyFiles = Files.SA         ; Points to Files.SA for files to copy
    CESetupDLL= StartUp.dll

    [SourceDisksNames.SA]
    1 = ,"Files",,.\DeviceID_CellID

    [SourceDisksNames.ARM]
    2 = ,"ARM Files",,.\DeviceID_CellID\Smartphone 2003 (ARMV4)\Release

    [SourceDisksFiles.SA]
    StartUp.dll = 1

    [SourceDisksFiles.ARM]
    DeviceID_CellID.exe = 2

    [Files.SA]
    StartUp.dll,,,0

    [DestinationDirs]
    Files = 0,%InstallDir%
    Shortcuts = 0,%CE11%             ; \Windows\Start Menu\Programs
    Files.SA = 0, %InstallDir%

    [Files]
    DeviceID_CellID.exe

    [Shortcuts]
    %AppName%,0,DeviceID_CellID.exe

    Your early reply will be appreciated. Thanking you,

    Regards,

    Parag


  • Launch the dll at install time