编译通过了,可是链接有三个错误:(请高手指点!)我是在VC6.0下调试的.wincre.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/wincre.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.程序如下:
#include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; // 窗口样式,一般设置为0
wndclass.lpfnWndProc = WndProc ;// 指向窗口函数的指针
wndclass.cbClsExtra = 0 ;// 分配在窗口类结构后的字节数
wndclass.cbWndExtra = 0 ;// 分配在窗口实例后的字节数
wndclass.hInstance = hInstance ;//定义窗口类的应用程序的实例句柄
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;//窗口类的图标
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;// 窗口类的光标
wndclass.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ;// 窗口类的背景刷
wndclass.lpszMenuName = NULL ;// 窗口类的菜单资源名
wndclass.lpszClassName= szAppName ;// 窗口类名
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow( szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT,// initial x position
CW_USEDEFAULT,// initial y position
CW_USEDEFAULT,// initial x size
CW_USEDEFAULT,// initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
switch (message)
{
case WM_CREATE:
PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam);}
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/wincre.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.程序如下:
#include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; // 窗口样式,一般设置为0
wndclass.lpfnWndProc = WndProc ;// 指向窗口函数的指针
wndclass.cbClsExtra = 0 ;// 分配在窗口类结构后的字节数
wndclass.cbWndExtra = 0 ;// 分配在窗口实例后的字节数
wndclass.hInstance = hInstance ;//定义窗口类的应用程序的实例句柄
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;//窗口类的图标
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;// 窗口类的光标
wndclass.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ;// 窗口类的背景刷
wndclass.lpszMenuName = NULL ;// 窗口类的菜单资源名
wndclass.lpszClassName= szAppName ;// 窗口类名
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow( szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT,// initial x position
CW_USEDEFAULT,// initial y position
CW_USEDEFAULT,// initial x size
CW_USEDEFAULT,// initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
switch (message)
{
case WM_CREATE:
PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam);}
解决方案 »
- atl向导生成的proxy/stub文件,前面的小红圈是怎么出来的?
- \Device\Harddisk0\Partition5 如何获取?
- udp通讯程序的问题.大家帮我分析一下
- 怎样调用自己生成的Generic class!!
- 病痛月余,不见大好。郁闷异常,散分!
- 谁能解释一下DLG初始化函数内的这段代码
- 如何先将要绘制的图像先在内存中编辑之后再在屏幕上显示,希望有精炼的代码
- 如何做到点击网页上的一个“EXE"文件的连接时自动运行该文件而不是提示下载该文件?
- 实现将一台服务器上正运行的内容同步显示?
- 菜鸟求教。
- dlgdata.cpp line 43棘手的问题
- 控制光驱进出的代码,我有2个光驱,要能够选择控制哪一个
需要加入库winmm.lib
#pragma comment(lib,"winmm.lib")unresolved external symbol _main 工程属性问题 用Win32APP