locked
Smart Device Cab Project RRS feed

  • Question

  • Hi,

    I am writing cab file for deployment using Smart Device Cab Project with a SetupDLL. From this DLL I want to display a dialog and read settings from embedded file and display from same file, but file should not be deployed to device. Here is how I am thinking to do it.

    First, I add DllMain so I can get an HINSTANCE;

    BOOL APIENTRY DllMain(HANDLE handle, DWORD  ul_reason_for_call, LPVOID lpReserved) {
     if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
      hInstance = (HINSTANCE)handle;
      hModule = (HMODULE)handle;
     }
     return TRUE;
    }

    Inside of Install_Init() function I invoke my dialog;

    codeINSTALL_INIT Install_Init(HWND hwndParent, BOOL fFirstCall, BOOL fPreviouslyInstalled, LPCTSTR pszInstallDir ) {
       if (!fFirstCall)
          return ShowDialog(hwndParent, pszInstallDir);
       else
          return codeINSTALL_INIT_CANCEL;
    }
    Here is code for ShowDialog;
    codeINSTALL_INIT ShowDialog(HWND hWndParent, LPCTSTR pszInstallDir) {
    
       pszInstallationDir = pszInstallDir;
       return (codeINSTALL_INIT)DialogBox(hInstance, MAKEINTRESOURCE(IDD_POCKETPC_LANDSCAPE), NULL, (DLGPROC)DlgProc);
    }

    Questions:

    1. Should I create Dialog from 'BOOL WINAPI DllMain(..)' using CreateDialog() Function?
    2. Before Showing, or creating if I must use CreateDialog(), should DLL Thread notifications be stopped via DisableThreadLibraryCalls() function?
    3. How to embed a text file in Smart Device Cab Project .cab file but NOT DEPLOY it!
    4. Read custom settings from file and write to registry. 
    5. Read EULA text from file and display  in dialog box created above.

    Also, in ShowDialog() I get hInstance from DllMain(), should I be somehow using SetupDLL? If so, How do  I obtain it? I dumnped contents of a .cab file already and It does some funny stuff to Name so it may not be called SetupDLL anymore. This complicates calling GetModuleInstance(). In addition, did not know if one should create ATL Smart Device Cab Project or Win32 Smart Device Cab Project. Code above assumes Win32 type.


    Thanks

    Friday, July 31, 2009 9:31 PM

Answers

  • Hi,

    For text file, you can add it in resource of setupdll project as custom resource.
    And load resource in your dialog and show it.
    You have to create dialog in Install_Init() or Install_Exit() functions.
    But for "Read custom settings from file and write to registry "
    You have to deploy the setting file on device.
    You can do this in Install_Exit() function.

    Regards,
    Pariksheet.
    Tuesday, August 4, 2009 4:50 AM
  • Hi Mobile Applications Developer,

    The problem should be that you miss a configuation, please following the steps:

    1. Click CAB project and let the project get focus
    2. Click "Properties Window"
    3. You will see "CE Setup DLL" setting
    4. Select the your setup dll


    As I follow the steps above, I can show the dialog as expected.


    If you have further question, please let me know.

    Since the thread will be expired, I will handle it, we can still continue to discuss it in this thread.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, August 7, 2009 4:03 AM

All replies

  • Hi,

    For text file, you can add it in resource of setupdll project as custom resource.
    And load resource in your dialog and show it.
    You have to create dialog in Install_Init() or Install_Exit() functions.
    But for "Read custom settings from file and write to registry "
    You have to deploy the setting file on device.
    You can do this in Install_Exit() function.

    Regards,
    Pariksheet.
    Tuesday, August 4, 2009 4:50 AM
  • Hi Mobile Applications Developer [MAD],

    In addition to Pariksheet's reply, although we have to deploy the file to device, we can delete after installation in Install_Exit method. Please try it.

    If you have further question, please let me know.



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Tuesday, August 4, 2009 9:20 AM
  • Yes, Well, actually I do create the dialog in Install_Init() by calling function ShowDialog() from Install_Init().

    here is SetupDLL : http://home.comcast.net/~erica.ramsey/SetupHelperDLL.zip


    Any help appreciated!

    Thanks

    Wednesday, August 5, 2009 7:47 PM
  • Hi Mobile Applications Developer [MAD],

    So what's your question? Does the code not work?



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Thursday, August 6, 2009 9:49 AM
  • I does not work, the Dialog exits immediately when a button is pressed and skips other code I have i invoker of the dialog. Any example code of how to create dialog inside of setup dll?
    Thursday, August 6, 2009 2:21 PM
  • Hi Mobile Applications Developer,

    The problem should be that you miss a configuation, please following the steps:

    1. Click CAB project and let the project get focus
    2. Click "Properties Window"
    3. You will see "CE Setup DLL" setting
    4. Select the your setup dll


    As I follow the steps above, I can show the dialog as expected.


    If you have further question, please let me know.

    Since the thread will be expired, I will handle it, we can still continue to discuss it in this thread.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, August 7, 2009 4:03 AM
  • Hi Mobile Applications Developer,

    The problem should be that you miss a configuation, please following the steps:

    1. Click CAB project and let the project get focus
    2. Click "Properties Window"
    3. You will see "CE Setup DLL" setting
    4. Select the your setup dll


    As I follow the steps above, I can show the dialog as expected.


    If you have further question, please let me know.

    Since the thread will be expired, I will handle it, we can still continue to discuss it in this thread.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Sorry, you misundersetood me. I met that when install setupdll is ran. I can see the dialog but then it vanishes;

    This piece of code grabs HINSTANCE of SetupDLL I use it to create dialogbox
    // THIS GRABS INSTANCE HANDLE OF DLL
    BOOL APIENTRY DllMain( HANDLE handle, DWORD  ul_reason_for_call, LPVOID lpReserved) 
    {
        if (ul_reason_for_call == DLL_PROCESS_ATTACH)
        {
            hInstance = (HINSTANCE)handle;
            hModule = (HMODULE)handle;
        }
        return TRUE;
    }

    This piece of code calls method to create/show dialog;

    // THIS CODE SHOWS MY DIALOG
    codeINSTALL_INIT Install_Init(HWND hwndParent, BOOL fFirstCall, BOOL fPreviouslyInstalled, LPCTSTR pszInstallDir ) 
    {
        return ShowDialog(hwndParent, pszInstallDir);
    }
    This method creates/shows the dialog;
    01: codeINSTALL_INIT ShowDialog(HWND hWndParent, LPCTSTR pszInstallDir ){
    02:     mainHwnd = hWndParent;
    03:     pszInstallationDir = pszInstallDir;
    04:     int result = (codeINSTALL_INIT) DialogBox(hInstance,
    05:             MAKEINTRESOURCE(IDD_POCKETPC_LANDSCAPE),
    06:             hWndParent, (DLGPROC)DlgProc);

    07:     if (result == IDOK){
    08:         MessageBox(0, _T("ShowDialog"), _T("DlgProc.Results=OK"), MB_OK);
    09:         return codeINSTALL_INIT_CONTINUE;
    10:     }
    11:     else {
    12:         MessageBox(0, _T("ShowDialog"), _T("DlgProc.Results=CANCEL"), MB_OK);
    13:         return codeINSTALL_INIT_CANCEL;
    14:     }
    15: }
    When the the dialog never returns to line #5 it just exits and I get Install canceled. Code for dialog proc;
    int CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
        //UNREFERENCED_PARAMETER(lParam); //lParam is usually never used, so just unreference it
        int wmId, wmEvent;
    
        switch(uMsg) {
        case WM_INITDIALOG:
            SetDlgItemText(hWnd, IDC_AGREEMENT_TEXT, GetLicenseAgreement());
            return TRUE;
    
        case WM_COMMAND: //A button has been pressed ! Something has happened ! Let’s check what it was !
            wmId    = LOWORD(wParam);//makes life easier
            wmEvent = HIWORD(wParam);//makes life easier
            switch (wmId) {
            case IDC_AGREE_BUTTON:
                EndDialog(hWnd, IDOK);
                return true;
    
            case IDC_CANCEL_BUTTON:
                EndDialog(hWnd, IDCANCEL);
                return true;
            }
            break;
    
        case WM_CLOSE: //EndDialog must be called to close a DialogBox
            EndDialog(hWnd, codeINSTALL_INIT_CANCEL);
            break;
    
        case WM_DESTROY: //PostQuitMessage sends the dialog a signal to close
            PostQuitMessage(0);
            break;
    
        default: ; //just do nothing if none of those are the message
        }
        return 0;
    }
    

    Any ideas?
    Monday, August 10, 2009 3:20 PM
  • Hi Mobile Applications Developer [MAD],

    I got your idea. As you said, I can reproduce the problem. I also tried a sample in normal application, the parent dialog will not vanish, only in setupdll.  I suggest you submit a feedback to following link:

    https://connect.microsoft.com/VisualStudio/Feedback

     

    Thank you for your feedback.

     

    Best regards,
    Guang-Ming Bian - MSFT 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Tuesday, August 11, 2009 9:11 AM
  • Hello ,

    I am also doing the same stuff. I am getting the same result.

    Please help.

    Thanks.

    ~Mayur
    Wednesday, August 19, 2009 8:50 AM
  • Hello ,

    I am also doing the same stuff. I am getting the same result.

    Please help.

    Thanks.

    ~Mayur
    I do not know how to help yet... I'll keep thread updated though.
    Monday, August 24, 2009 2:58 PM