首页
社区
课程
招聘
[求助]尝试在VC6.0中调用asm子程序的试验
发表于: 2005-1-29 13:57 4380

[求助]尝试在VC6.0中调用asm子程序的试验

2005-1-29 13:57
4380
MixTest.cpp
/*----------------------------------------------------
     A simple program written to demonstrate mixed
	 programming of C and Asm
	       cyclotron [BCG][DFCG][FCG][OCN]
  ----------------------------------------------------*/

#include <windows.h>
#include "resource.h"

extern "C" long AsmProc(void);

LRESULT CALLBACK DialogProc (HWND, UINT, WPARAM, LPARAM);

int	WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPSTR lpCmdLine, int nShowCmd)
{
	DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG), 
		NULL, (DLGPROC)DialogProc, NULL);
	return	0;
}

LRESULT CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case	WM_INITDIALOG:
		break;

	case	WM_COMMAND:
		switch(wParam)
		{
			case	ID_OK:
				SetDlgItemText(hWnd, IDC_EDIT, (const char*)AsmProc());
				break;

			case	ID_EXIT:
				EndDialog(hWnd ,NULL);
		}
		return	0;

	case	WM_CLOSE:
		EndDialog(hWnd ,NULL);
		return	0;

	}

	return	0;
}


       
AsmProc.asm

;//////////////////////////////////////////////

;/////////////     MixTest      ///////////////

;///   by cyclotron[BCG][DFCG][FCG][OCN]   ////

;//////////////////////////////////////////////

.386

.model	flat,stdcall

option	casemap:none

include	windows.inc
include	kernel32.inc
include	user32.inc

includelib	kernel32.lib
includelib	user32.lib

.data

szTitle	db	'MixTest',0
szText	db	'MixTest',0

.code
public _AsmProc

_AsmProc	proc
	;invoke	MessageBox,NULL,offset szTitle,offset szText,MB_OK
	mov	eax,offset szText
	ret
_AsmProc	endp

	end
	


链接结果总是提示:

Linking...
MixTest.obj : error LNK2001: unresolved external symbol _AsmProc
Debug/MixTest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

MixTest.exe - 2 error(s), 0 warning(s)

请问是什么原因?

下载:MixAsm.rar

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 200
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
DEFSPROC MACRO PROCNAME, ARGS
ifdef __BORLANDC__
        PUBLIC PROCNAME
PROCNAME PROC STDCALL ARGS
else
PROCNAME PROC STDCALL PUBLIC ARGS
endif
        ENDM

;; Macro to define end of pubilc standard entry point

ENDSPROC MACRO PROCNAME
PROCNAME ENDP
        ENDM
2005-1-31 23:47
0
雪    币: 216
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
extern "C" long __stdcall _AsmProc(void);

Do It Like this,Have a test
2005-2-1 10:42
0
雪    币: 216
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
还有,link的时候记得把AsmProc.obj添加进去
2005-2-1 10:45
0
游客
登录 | 注册 方可回帖
返回
//