Re: Windows API in VC++

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 10/08/04


Date: Thu, 7 Oct 2004 22:16:24 -0400


"Alfred" <anonymous@discussions.microsoft.com> wrote...
>I have look at the code reference, and this is my code:
>
> HWND hWnd ;
> int Rtval = ShellExecute(hWnd, "Open", "notepad.exe", NULL, NULL, 0);
>
> I always get error during compile:
> error C2440: 'initializing' : cannot convert from 'struct HINSTANCE__ *'
> to 'int'
>
> can anyone help me this? i'm new in this...

(a) You must pass a _real_ window as the first argument. You cannot
pass an uninitialised variable. 'ShellExecute' will use it to create
error message boxes. You could try to pass NULL there, but don't
quote me on that.

(b) 'ShellExecute' returns HINSTANCE, not an int. The return value
needs to be assigned to an HINSTANCE variable.

   HINSTANCE hInst = ShellExecute(hSomeRealWindow, ...

Get a good book and don't substitute serious study with reading the
reference and posting to a newsgroup.

Victor



Relevant Pages

  • Re: Build Errors
    ... However this is the first time in all my examples that I had ... >> int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInnstance, ... >> LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM ...
    (microsoft.public.vc.language)
  • RE: MoveWindow not sending WM_SIZE on deeply nested windows
    ... > window whose size I've requested to change. ... > int find_window (HWND hwnd) { ... > void display_error { ...
    (microsoft.public.win32.programmer.ui)
  • Re: Button with Bitmap Disabled problem
    ... LRESULT CALLBACK ButtonProc (HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM ... BOOL DitherBlt(HDC hDestDC, int x, int y, int nWidth, int nHeight, HDC ...
    (microsoft.public.win32.programmer.ui)
  • Re: Build Errors
    ... void Show (HWND hwnd, HDC hdc, int xText, int yText, int iMapMode, ... LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM ...
    (microsoft.public.vc.language)