Jump to content
  • Advertisement
Sign in to follow this  
chennaiaras

The program xxx.exe:Native has exited with code 0

This topic is 3070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

I started programming to create a window. I am using visual C++ 2008 express edition. My program is compiling without any errors / warnings. But when i execute it shows the following and the window doesn't appear.

'ballgame.exe': Loaded 'D:\Aras projects\directX\ballgame\Debug\ballgame.exe', Symbols loaded.
'ballgame.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
'ballgame.exe': Loaded 'C:\Program Files\Airtel PC Secure\HIPS\fshook32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
The program '[868] ballgame.exe: Native' has exited with code 0 (0x0).

what's the issue. Can anyone help me to resolve this.

regards,
aras

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by chennaiaras
Hi

I started programming to create a window. I am using visual C++ 2008 express edition. My program is compiling without any errors / warnings. But when i execute it shows the following and the window doesn't appear.

'ballgame.exe': Loaded 'D:\Aras projects\directX\ballgame\Debug\ballgame.exe', Symbols loaded.
'ballgame.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
'ballgame.exe': Loaded 'C:\Program Files\Airtel PC Secure\HIPS\fshook32.dll'
'ballgame.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
The program '[868] ballgame.exe: Native' has exited with code 0 (0x0).

what's the issue. Can anyone help me to resolve this.

regards,
aras


Okay, so this is just a .cpp file with int main() { return 0; } right?

If so, before the return 0 you just need to put something to halt the execution, system("PAUSE"); or some other form of halting should do fine.

Share this post


Link to post
Share on other sites
Please post the code if you want any help with it.
And that is debug information you shouldn't worry about.

I think it's what Kalnos said.
The Window in which the program runs closes as soon as the program is finished, if it's doing nothing, then it will get closed as soon as it opens.

Add
#include <iostream>

to the beginning of the code if not already there.
And add this before the return 0 (The 0 could be something else, like EXIT_SUCCESS or might not even be there, in that case before }) in your main function
cin.get();

like so:

int main(int argc, char* argv[])
{
...
cin.get();
return 0;
}

Share this post


Link to post
Share on other sites
Hi all,

Thanks for ur replies... I tried with getchar() also. The same thing continues.

This is my code..

#include <windows.h>
#include <iostream>

HINSTANCE hInst;
HWND wndHandle;

bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int lCmdShow) {
if(!initWindow(hInstance))
return false;

MSG msg;
ZeroMemory(&msg, sizeof(msg));
while(msg.message!=WM_QUIT) {
while(GetMessage(&msg, wndHandle, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
getchar();
return (int) msg.wParam;
}

bool initWindow(HINSTANCE hInstance) {
WNDCLASSEX wcex;

wcex.cbClsExtra =0;
wcex.cbSize =sizeof(WNDCLASSEX);
wcex.cbWndExtra =0;
wcex.hbrBackground =(HBRUSH)(COLOR_WINDOW+1);
wcex.hCursor =LoadCursor(NULL, IDC_ARROW);
wcex.hIcon =0;
wcex.hIconSm =0;
wcex.hInstance =hInstance;
wcex.lpfnWndProc =(WNDPROC)WndProc;
wcex.lpszClassName =NULL;
wcex.lpszMenuName =NULL;
wcex.style =CS_HREDRAW | CS_VREDRAW;

RegisterClassEx(&wcex);

wndHandle =CreateWindow(NULL,NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL,
hInstance, NULL);

if(!wndHandle)
return false;

ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case WM_DESTROY :
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}

regards,
aras


Share this post


Link to post
Share on other sites
You've got several problems. Out of curiosity, VC Express will create projects for you, will it not? If so, perhaps better to create a default window project than write your own code.

Your biggest problem: you don't tell yourself when an error occurs. There are several errors in your program which you could debug yourself using OutputDebugString().

E.g.,

ATOM atom = RegisterClassEx(..);
if( atom==NULL )
{
OutputDebugString("Register class failed\n");
return false;
}


In any case:

You try to register a window class with no name. Doesn't work.

You try to create a window without a class name. Doesn't work.

You don't need to check for msg = WM_QUIT. Let the window procedure handle it all for you.

Your GetMessage function checks only for the window, not the thread. Change to:
GetMessage(&msg,NULL,0,0)

So:
fix the class registration (and check for success).
fix the create window call.

change your message loop to:

MSG msg;
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

Share this post


Link to post
Share on other sites
Hi Buckeye

I tried giving the window a class name and that gives me an compilation error.

the code is :

bool initWindow(HINSTANCE hInstance) {
WNDCLASSEX wcex;

wcex.cbClsExtra =0;
wcex.cbSize =sizeof(WNDCLASSEX);
wcex.cbWndExtra =0;
wcex.hbrBackground =(HBRUSH)(COLOR_WINDOW+1);
wcex.hCursor =LoadCursor(NULL, IDC_ARROW);
wcex.hIcon =0;
wcex.hIconSm =0;
wcex.hInstance =hInstance;
wcex.lpfnWndProc =(WNDPROC)WndProc;
wcex.lpszClassName ="Window";
wcex.lpszMenuName ="WindowSample";
wcex.style =CS_HREDRAW | CS_VREDRAW;

if(!RegisterClassEx(&wcex)) {
MessageBoxA(NULL,"Window registration failed", "Error!", MB_ICONEXCLAMATION | MB_OK);
return false;
}

wndHandle =CreateWindow("window","window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL,
hInstance, NULL);

if(!wndHandle) {
MessageBoxA(NULL,"Window creation failed", "Error!", MB_ICONEXCLAMATION | MB_OK);
return false;
}

ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}

and the error is :

d:\aras projects\directx\ballgame\ball_game.cpp(38) : error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>d:\aras projects\directx\ballgame\ball_game.cpp(39) : error C2440: '=' : cannot convert from 'const char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

what is the difference between LPSTR and LPCWSTR..? When i try to change this in 'WinMain'.. that throws me 'WinMain' overloaded error.

what is the solution... Don't mind.I am entirely new to this.

regards,
aras

Share this post


Link to post
Share on other sites
There's a couple of different things you could do here:

One of the following:
1) Disable unicode (all functions/classes will default to -A)
2) Change "WNDCLASSEX wcex" to "WNDCLASSEXA wcex" (A-ending)
3) change wcex.lpszClassName ="Window"; wcex.lpszMenuName ="WindowSample"; to wcex.lpszClassName = L"Window";
wcex.lpszMenuName = L"WindowSample";


L"this is a text string" is the unicode way to do it.

SomeFunctionW(L"unicode string");
SomeFunctionA("not unicode");

Share this post


Link to post
Share on other sites
First: if VS will generate a project for you, you can look at it and learn a lot.

Second: look at the docs for WNDCLASSEX to see what you should be putting in it, and why.

Have you created a menu? If not, you'll have a problem trying to set a menu name in WNDCLASSEX. See the docs for WNDCLASSEX. Just leave it NULL for now.

By the way, if you disable Unicode (i.e., use Multibyte instead), then you don't need to change your strings.

Also, consider using [code] [/code] or [source] [/source] tags to post code. It helps readability a lot. See the faq (upper-righthand corner of this screen) for info about tags.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!