| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1630 人关注过本帖
标题:[求助]第一次编译连接正切,第二次..
取消只看楼主 加入收藏
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
 问题点数:0 回复次数:8 
[求助]第一次编译连接正切,第二次..

第一次编译连接正常无错误,就是运行时没有效果
第二次 编译,连接时
Linking...
LINK : fatal error LNK1168: cannot open Debug/5.exe for writing
Error executing link.exe.

5.exe - 1 error(s), 0 warning(s)

这是什么错误呢?
(windows编程)
建立的工程是Win32 Application

搜索更多相关主题的帖子: 正切 LINK windows 编译 
2006-09-01 00:24
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

三个文件,分别是:
//-----------------------5_2.h-------------------
#define IDM_NEW 10
#define IDM_OPEN 11
#define IDM_CLOSE 12
#define IDM_SAVE 13
#define IDM_SAVEAS 14
#define IDM_ADDPRINTMENU 15
#define IDM_DELPRINTMENU 16
#define IDM_EXIT 17
#define IDM_CUT 18
#define IDM_COPY 19
#define IDM_PASTE 20
#define IDM_DELETE 21
#define IDM_HELP 22
#define IDM_LINE 23
#define IDM_RECT 24
#define IDM_RRECT 25
#define IDM_ELLIP 26

//-----------------------52.rc--------------------------
#include <windows.h>
#include "5_2.h"
MENU MENU DISCARDABLE

BEGIN
POPUP "文件(&F)"
BEGIN
MENUITEM "新建(&N)\t Ctrl+N", IDM_NEW
MENUITEM " 打开(&0)\T Ctrl+O", IDM_OPEN
MENUITEM " 关闭(&C)", IDM_CLOSE
MENUITEM SEPARATOR
MENUITEM "保存(&S)\t Ctrl+S", IDM_SAVE
MENUITEM "另存为(&A)", IDM_SAVEAS
MENUITEM SEPARATOR
MENUITEM "创建统计计算彩单项(&P)\T Ctrl+P", IDM_ADDPRINTMENU
MENUITEM "删除统计计算彩单项(&D)\T Ctrl+D", IDM_DELPRINTMENU,GRAYED
MENUITEM SEPARATOR
MENUITEM "退出(&X)", IDM_EXIT
END

POPUP "编辑(&E)"
BEGIN

MENUITEM "剪切(&T)\t Ctrl+X", IDM_CUT
MENUITEM "复制(&C)\t Ctrl+C", IDM_COPY
MENUITEM "粘贴(&P)\t Ctrl+V", IDM_PASTE
MENUITEM "删除(&D)\T Del", IDM_DELETE
END

MENUITEM "帮助(&H)", IDM_HELP
END

MENU ACCELERATORS MOVEABLE PURE
BEGIN
"^N", IDM_NEW, ASCII
"^O", IDM_OPEN, ASCII
"^S", IDM_SAVE, ASCII
"^P", IDM_ADDPRINTMENU, ASCII
"^D", IDM_DELPRINTMENU, ASCII
"^X", IDM_CUT, ASCII
"^C", IDM_COPY , ASCII
"^V", IDM_PASTE , ASCII
VK_DELETE, IDM_DELETE, VIRTKEY
END

//-----------------------5.cpp-------------------------
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
...........................

帮忙一下,大虾们


2006-09-01 09:00
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

早上又重新试了一下,又是没看到运行结果
//------------------5.CPP--------------
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
HACCEL hAccel;
WNDCLASS WndClass;
char lpszMenuName[] = "Menu";
char lpszClassName[] = "彩单";
char lpszTitle[] = "My_Menu_Example";
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClassName;
WndClass.lpszMenuName = lpszMenuName;
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
}
hwnd = CreateWindow("5_1",
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
hAccel = LoadAccelerators(hInstance,lpszMenuName);
while(GetMessage(&Msg,NULL,0,0))
{
if(!TranslateAccelerator(hwnd,hAccel,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_NEW: break;
case IDM_OPEN: break;
case IDM_SAVE: break;
case IDM_SAVEAS: break;
case IDM_CLOSE :break;
case IDM_ADDPRINTMENU:
hmenu = GetMenu(hwnd);
hprintmenu = CreateMenu();
AppendMenu(hprintmenu,MF_ENABLED,IDM_LINE,"求和");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RECT,"方差");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RRECT,"平均值");
AppendMenu(hprintmenu,MF_ENABLED,IDM_ELLIP,"均方根");
InsertMenu(hmenu,2,MF_POPUP|MF_BYPOSITION,(UINT)hprintmenu,"统计计算(&C)");
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_GRAYED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_ENABLED);
DrawMenuBar(hwnd);
break;
case IDM_DELPRINTMENU:
DeleteMenu(hmenu,2,MF_BYPOSITION);
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_ENABLED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_GRAYED);
DrawMenuBar(hwnd);
break;
case IDM_EXIT:
SendMessage(hwnd,WM_DESTROY,0,0);
break;
case IDM_CUT: break;
case IDM_COPY: break;
case IDM_PASTE: break;
case IDM_DELETE: break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}


帮我看看吧


2006-09-01 09:14
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
谢谢!大姐!
我按照了你的建议修改了程序,可运行结果不知道怎么没有显示彩单

2006-09-01 16:25
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
这是修改后的.CPP文件
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
HACCEL hAccel;
WNDCLASS WndClass;
char lpszMenuName[] = "Menu";
char lpszClassName[] = "彩单";
char lpszTitle[] = "My_Menu_Example";
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClassName;
WndClass.lpszMenuName = lpszMenuName;
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
}
hwnd = CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
hAccel = LoadAccelerators(hInstance,lpszMenuName);
while(GetMessage(&Msg,NULL,0,0))
{
if(!TranslateAccelerator(hwnd,hAccel,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_NEW: break;
case IDM_OPEN: break;
case IDM_SAVE: break;
case IDM_SAVEAS: break;
case IDM_CLOSE :break;
case IDM_ADDPRINTMENU:
hmenu = GetMenu(hwnd);
hprintmenu = CreateMenu();
AppendMenu(hprintmenu,MF_ENABLED,IDM_LINE,"求和");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RECT,"方差");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RRECT,"平均值");
AppendMenu(hprintmenu,MF_ENABLED,IDM_ELLIP,"均方根");
InsertMenu(hmenu,2,MF_POPUP|MF_BYPOSITION,(UINT)hprintmenu,"统计计算(&C)");
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_GRAYED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_ENABLED);
DrawMenuBar(hwnd);
break;
case IDM_DELPRINTMENU:
DeleteMenu(hmenu,2,MF_BYPOSITION);
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_ENABLED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_GRAYED);
DrawMenuBar(hwnd);
break;
case IDM_EXIT:
PostMessage(hwnd,WM_CLOSE,0,0);
break;
case IDM_CUT: break;
case IDM_COPY: break;
case IDM_PASTE: break;
case IDM_DELETE: break;
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}

2006-09-01 16:27
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

不知道怎么弄,一直行不通,显示不了菜单

yeshirow

帮我改一下这个程序吧

第一次做这样的练习,网上找不到用API创建菜单的例子,能给我推荐一本关于这方面的书吗?谢谢!


2006-09-02 10:15
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
我想问题应该是在WinMain()函数里面,WndProc()是教程上有的

2006-09-02 12:41
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
xiexie
不行,算了,费了我很长时间了

2006-09-02 23:24
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

呵呵,重新建立了个工程,可以了.


2006-09-03 10:08
快速回复:[求助]第一次编译连接正切,第二次..
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.062309 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved