CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Posts
    6

    VC++ .NET and winapi

    I have a problem with managed c++. I try to use a ExitWindowsEx, winaipi function to turn off my computer, but a compiler doesn't find this function. Maybe somebody had the same problem ?

  2. #2
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: VC++ .NET and winapi

    Do you have the platform SDK installed? You can find it on microsoft.com.

    Also note:
    http://msdn.microsoft.com/library/de...ws_headers.asp


    And finally:

    You can use LoadLibrary(...)/GetProcAddress(...) if you need to.

  3. #3
    Join Date
    Nov 2004
    Posts
    6

    Re: VC++ .NET and winapi

    But which library I have to add, I truly don't know. Oh I instaled a SKD but compiler still has a C3861 error.

  4. #4
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: VC++ .NET and winapi

    Go to tools->options [project and solutions] VC++ Directories and make sure the <SDK install dir>\include is at the top (under includes) and the <SDK install dir>\lib is at the top (under libs)

    ExitWindowsEx is in winuser.h.

    http://msdn.microsoft.com/library/de...twindowsex.asp

    So:
    #include <windows.h>

    You also need to link with user32.lib, so add it to your linker settings or add a pragma:
    #pragma comment(lib,"user32")

    Code:
    WINUSERAPI
    BOOL
    WINAPI
    ExitWindowsEx(
        IN UINT uFlags,
        IN DWORD dwReserved);

  5. #5
    Join Date
    Nov 2004
    Posts
    6

    Re: VC++ .NET and winapi

    Thank you , now it's working. I propably never guess way to repair it.

  6. #6
    Join Date
    Nov 2004
    Posts
    6

    Re: VC++ .NET and winapi

    I hava another problem, ehwn I try to add bacground picture to a button when I add picture in properties VC++ added line
    this->pictureBox1->BackgroundImage = (__try_cast<System:rawing::Image * >(resources->GetObject(S"pictureBox1.BackgroundImage")));

    and compiler say :

    d:\Visual Studio Projects\Programy\Wylacz Mnie\Form1.h(103): error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'

  7. #7
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: VC++ .NET and winapi

    Quote Originally Posted by Assassin
    I hava another problem, ehwn I try to add bacground picture to a button when I add picture in properties VC++ added line
    this->pictureBox1->BackgroundImage = (__try_cast<System:rawing::Image * >(resources->GetObject(S"pictureBox1.BackgroundImage")));

    and compiler say :

    d:\Visual Studio Projects\Programy\Wylacz Mnie\Form1.h(103): error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'
    Well because you are including <windows.h> you are picking up the macro defines for GetObject

    Which translates to GetObjectA or GetObjectW.

    use a push_macro/pop_macro in your form1.h

    #pragma push_macro("GetObject")
    #undef GetObject

    [body of code]
    ...
    ...

    #pragma pop_macro("GetObject")

  8. #8
    Join Date
    Nov 2004
    Posts
    6

    Re: VC++ .NET and winapi

    thanky you now it's working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured