调用.DLL出现“非法操作”(运行时)错误提示?是什么问提?请大师指点!
调用.DLL出现“非法操作”(运行时)错误提示?是什么问提?请大师指点!源程序如下:
#if !defined(AFX_TEST22DDIALOG_H__FBA991A7_FBA4_11D5_8B4E_814E9B0B2013__INCLUDED_)
#define AFX_TEST22DDIALOG_H__FBA991A7_FBA4_11D5_8B4E_814E9B0B2013__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Test22dDialog.h : header file
//
extern "C" _declspec(dllimport) void Ex22dEntry();
#define RYG_SETSTATE WM_USER+0
#define RYG_GETSTATE WM_USER+1
/////////////////////////////////////////////////////////////////////////////
// CTest22dDialog dialog
class CTest22dDialog : public CDialog
{
// Construction
public:
CTest22dDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTest22dDialog)
enum { IDD = IDD_TEST22DDIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTest22dDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTest22dDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
afx_msg void OnClickedRyg();
DECLARE_MESSAGE_MAP()
private:
enum{OFF,RED,YELLOW,GREEN}m_nState;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEST22DDIALOG_H__FBA991A7_FBA4_11D5_8B4E_814E9B0B2013__INCLUDED_)
// Test22dDialog.cpp : implementation file
//
#include "stdafx.h"
#include "EX22B.h"
#include "Test22dDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTest22dDialog dialog
CTest22dDialog::CTest22dDialog(CWnd* pParent /*=NULL*/)
: CDialog(CTest22dDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CTest22dDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nState=OFF;
Ex22dEntry();//Makesure DLL gets loaded
}
void CTest22dDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTest22dDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTest22dDialog, CDialog)
//{{AFX_MSG_MAP(CTest22dDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
ON_CONTROL(0,IDC_RYG,OnClickedRyg)//Notification code is 0
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTest22dDialog message handlers
void CTest22dDialog::OnClickedRyg()
{
switch(m_nState){
case OFF:
m_nState=RED;
break;
case RED:
m_nState=YELLOW;
break;
case YELLOW:
m_nState=GREEN;
break;
case GREEN:
m_nState=OFF;
break;
}
GetDlgItem(IDC_RYG)->SendMessage(RYG_SETSTATE,m_nState);
return;
}
#if !defined(AFX_TESTEX22CDIALOG_H__9B7DA9CE_FD07_11D5_8B4E_F92D2BCCC512__INCLUDED_)
#define AFX_TESTEX22CDIALOG_H__9B7DA9CE_FD07_11D5_8B4E_F92D2BCCC512__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TestEX22cDialog.h : header file
//
extern "C" _declspec(dllimport) double Ex22cSquareRoot(double d);
/////////////////////////////////////////////////////////////////////////////
// CTestEX22cDialog dialog
class CTestEX22cDialog : public CDialog
{
// Construction
public:
CTestEX22cDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTestEX22cDialog)
enum { IDD = IDD_EX22C };
double m_dInput;
double m_dOutput;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestEX22cDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTestEX22cDialog)
afx_msg void OnComputesqurt();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TESTEX22CDIALOG_H__9B7DA9CE_FD07_11D5_8B4E_F92D2BCCC512__INCLUDED_)
// TestEX22cDialog.cpp : implementation file
//
#include "stdafx.h"
#include "EX22B.h"
#include "TestEX22cDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestEX22cDialog dialog
CTestEX22cDialog::CTestEX22cDialog(CWnd* pParent /*=NULL*/)
: CDialog(CTestEX22cDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestEX22cDialog)
m_dInput = 0.0;
m_dOutput = 0.0;
//}}AFX_DATA_INIT
}