本文介绍了clr应用程序中的mfc dll错误或win32 dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个mfc dll,它是一个mfc控制台应用程序,我想将代码作为dll添加到clr c ++ aoo。
控制台代码:
I have an mfc dll, it was an mfc console application which I want to add the code as dll to a clr c++ aoo.
code of console :
#include <windows.h>
#include <iostream>
#include <complex>
void main()
{
double i,c,d,f,g,e;
HDC hdc = GetDC(GetDesktopWindow());
DWORD ret = GetDeviceCaps(hdc, HORZSIZE);
DWORD ret2 = GetDeviceCaps(hdc, VERTSIZE);
std::cout << "Your screen size in inches is " << ret/25.4 << "\" x " << ret2/25.4 << "\" \n";
ReleaseDC(GetDesktopWindow(), hdc);
i=ret/25.4;
c=ret2/25.4;
d=0;
f=0;
d=((i*i)+(c*c));
g=sqrt(d);
std::cout << "Your screen size in inches is " << g << "\" \n";
getchar();
}
mydll.dll代码(mydll.cpp):
code of mydll.dll (mydll.cpp):
// mydll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "mydll.h"
#include <windows.h>
#include <iostream>
#include <complex>
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//
//TODO: If this DLL is dynamically linked against the MFC DLLs,
// any functions exported from this DLL which call into
// MFC must have the AFX_MANAGE_STATE macro added at the
// very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
// CmydllApp
BEGIN_MESSAGE_MAP(CmydllApp, CWinApp)
END_MESSAGE_MAP()
// CmydllApp construction
CmydllApp::CmydllApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CmydllApp object
CmydllApp theApp;
// CmydllApp initialization
BOOL CmydllApp::InitInstance()
{
CWinApp::InitInstance();
return TRUE;
}
void MyWin32ClassTwo()
{
double i,c,d,f,g,k;
char l;
HDC hdc = GetDC(GetDesktopWindow());
DWORD ret = GetDeviceCaps(hdc, HORZSIZE);
DWORD ret2 = GetDeviceCaps(hdc, VERTSIZE);
ReleaseDC(GetDesktopWindow(), hdc);
i=ret/25.4;
c=ret2/25.4;
d=0;
f=0;
d=((i*i)+(c*c));
g=sqrt(d);
}
如何创建dll并添加到win32 form(clr)应用程序并调用dll的g变量,是吗必须在dll中创建函数吗?
简单的答案请我是C ++的新手。
简单的如何在C ++ clr表单Project中获取监视器的horzsize。 />
谢谢
how to create dll and add to win32 form (clr) application and call the dll's g variable, do I have to create function in dll?
simple answer please I am NEW to C++.
In simple how to get the horzsize of monitor in a C++ clr forms Project.
Thank you
推荐答案
这篇关于clr应用程序中的mfc dll错误或win32 dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!