#### Archived

This topic is now archived and is closed to further replies.

# Initializing direct x help

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

## Recommended Posts

Im new to windows programming and have it set up correctly with my compiler (MVC++) But whne I run this program:
  #include #include #include LRESULT CALLBACK WndProc(HWND hwnd,UINT imessage,WPARAM wparam,LPARAM lparam) { switch(imessage) { case WM_CLOSE: case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,imessage,wparam,lparam); } return 0; } const char *Cname="Tutorial",*Wname="Tutorial"; int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE,LPSTR,int nCmdShow) { LPDIRECTDRAW lpdd; HRESULT ddrval; HWND hwnd; MSG message; WNDCLASS wndclass; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hIcon=LoadIcon(hinstance,NULL); wndclass.lpfnWndProc=WndProc; wndclass.style=CS_HREDRAW/CS_VREDRAW; if(!RegisterClass(&wndclass))return false; hwnd=CreateWindow(Cname,Wname,WS_OVERLAPPEDWINDOW,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hinstance,NULL); ShowWindow(hwnd,nCmdShow); while(GetMessage(&message,hwnd,0,0)) { TranslateMessage(&message); DispatchMessage(&message); } ddrval=DirectDrawCreate(NULL,&lpdd,NULL); if(ddrval!=DD_OK) MessageBox(NULL,"Error creating DX!","ERROR",MB_OK); ddrval=lpdd->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE/DDSCL_FULLSCREEN); if(ddrval!=DD_OK) MessageBox(NULL,"Error Setting Coop Lev","ERROR",MB_OK); return message.wParam; } 
It compiles right but gives me two errors when I try and execute it one is UNRESOLVED EXTERNAL SYMBOL _DirectDrawCreat@12 the other is fatal error LNK1120: 1 unresolved external if I take out the code ddrval=lpdd->SetCooperativeLevel ect... it compiles and executes fine. Can someone please help

##### Share on other sites
Hmmm, you''ll need more than me, but if I remember correctly DirectDrawCreate is the only function that is not part of the com interface, so it''d have something to do with your lib maybe. Do you have the ddraw.lib included? Casue the second error, is just an indication of the first error.
You also wrote "_DirectDrawCreat" in the error message report. Your missing the e on there so either you misspelled it on your post or you may have misspelled it in your program! Which would make it hard to find that procedure.
Hope this helped!
See ya,
Ben

##### Share on other sites
I had an error initializing ALOT like this, I never found the way to fix it, but I did get around it.
I copied the source code from one of the SDK programs, cut out the unnessicary parts, and then remade ddraw.lib (I use Borland, so I did it with implib on my ddraw.dll in windows\system).
My program works fine now, I hope this works for you.

BTW: You compiler should be able to catch those errors on compilation/linking, mine did when I had them (Mine had almost the exact same messages ...

• ### Forum Statistics

• Total Topics
628645
• Total Posts
2984020

• 9
• 9
• 10
• 21
• 20