将Win32项目转换为Win32控制台应用程序 [英] Converting a Win32 project to a Win32 console application

查看:175
本文介绍了将Win32项目转换为Win32控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Win32应用程序(Visual C ++ 6),它使用HINSTANCE来调用外部DLL。

我需要将它转换为一个控制台应用程序,它接受1个参数并回显结果因为我打算在linux上使用它(使用mono编译它)。

这是main.cpp的副本:

I have a Win32 application (Visual C++ 6) that uses HINSTANCE to call an external DLL.
I need to convert it to a console app that take 1 argument and echo the result because I intend of using it on linux (compiling it using mono).
Here is a copy of the main.cpp:

#include "stdafx.h"
#include "testlib.c"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{ 	
	LoadTestLibrary();

// etc....
}




testlib.c中的
我有:



in testlib.c I have:

HINSTANCE TESTLIB=NULL;

long LoadTestLibrary()
{
TESTLIB=LoadLibrary("TESTLIB.DLL");
if(TESTLIB == NULL)
 {
  MessageBox(NULL, "Unable to load TESTLIB.DLL", "ERROR", MB_OK);
  return(-1);
 }
else
 {
// process the data and echo the result
}



是否可以这样做。

谢谢


Is it possible to do it.
Thanks

推荐答案

你仍然需要为windows应用程序包含windows.h,即使它是一个控制台应用程序,因为你想要使用像LoadLibrary这样的调用,这些调用完全有效。



你显然需要删除显示窗口的消息框和其他调用,如果你你的程序根本不需要''窗口界面'。



我认为你提到的oriignal错误是因为它没有声明LoadLibrary函数。
You still need to include "windows.h" for the windows application even if it is a ''console'' application because you want to use calls like LoadLibrary and such, which are perfectly valid to call.

You obviously need to remove the message boxes and other calls that bring up windows, if you don''t want a ''window interface'' at all on your program.

I think the oriignal error you mentioned was because it did not have a declaration for LoadLibrary function.


这篇关于将Win32项目转换为Win32控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆