Raj Shukla

Hi Friends,

I have written one app for pocket pc 2003.Insatlled it,and run it.After that when i am trying to uninstall it when app is running i am trying to check in the Uninstall_Init function weather the app is running or not using "FindWindow" function.Here is the code......

codeUNINSTALL_INIT Uninstall_Init(HWND hwndParent,LPCTSTR pszInstallDir)

{ if (FindWindow(NULL,L"iPassConnect"))

{ MessageBox(hwndParent,L"Quit program before uninstalling it",L"Error",MB_OK);

return codeUNINSTALL_INIT_CANCEL;

}

else

{ MessageBox(hwndParent,L"After program before uninstalling it",L"Error",MB_OK);

DeleteDir(hwndParent,pszInstallDir);

return codeUNINSTALL_INIT_CONTINUE;

}

}

but the findwindow is not returning at all and the it hangs...after that i need to do a hard reset.

Pls help me...




Re: Smart Devices Native C++ Development FindWindow Function not working

r2d1

It would not surprise me if FindWindow is returning (null) and executes the 2nd messagebox but it doesn't show up because deletedir is causing a lockup. I'd comment out deletedir to see if this is the problem.



Re: Smart Devices Native C++ Development FindWindow Function not working

Puru Shukla

That is the problem....it's not comin inside the "else" even.So i am sure that deletedir is not causing problem.

I also took "FindWindow" outside and put one messagebox after that but even that messagebox is not coming

so it means that "FindWindow" is causing problem.






Re: Smart Devices Native C++ Development FindWindow Function not working

Saravanan V V

Hi

The FindWindow Api is not causing the issue may be some other lines of your code is causing the hang issue.





Re: Smart Devices Native C++ Development FindWindow Function not working

Zero Dai - MSFT

Dear Puru,

Would you please check the code that executes before uninstall_init function I have written a lot sample code on "FindWindow" function, but it always works fine.

Regards,

Zero Dai - MSFT






Re: Smart Devices Native C++ Development FindWindow Function not working

crino

maybe msgbox is in background
Try to add MB_SETFOREGROUND flag

:)





Re: Smart Devices Native C++ Development FindWindow Function not working

Kausik

Hi,

You are passing NULL in the class name. FindWindow may fail due to this. Can you please try by supplying the class name that you have supplied during creation of the window

There is a better approach though! You can set the GWL_USERDATA of the application with a unique ID from the WM_CREATE/WM_INITIDIALOG handler in the app.

case WM_INITDIALOG:

SetWindowLong(hDlg,GWL_USERDATA,0xA1B2C3D4);

break;

While uninstalling the app use EnumWindows to search the window!

........

EnumWindows(MyWindowEnum,0xA1B2C3D4);

if(g_hWnd !=NULL)

..............

BOOL MyWindowEnum(HWND pWnd,LPARAM pParam)

{

LONG lWndLng = GetWindowLong(pWnd,GWL_USERDATA);

if(lWndLng == (LONG)pParam)

{

g_hWnd = pWnd;

return FALSE;

}

return TRUE;

}

Less headache, better result! Enjoy Smile




Re: Smart Devices Native C++ Development FindWindow Function not working

Puru Shukla

thanx...