刚开始接触 VC++/CLI 这种语言,遇到很多问题,希望大家能给与帮助,先谢谢了!开发环境:VS2010    VC++/CLI    OS:Windows7     .NetVersion:4.0我的程序是这样的,先按通常方法创建了一个名为VC_KTKGK的VC项目,然后在项目里添加了一个VCTest.h的头文件,在这个头文件里声明了一些构造体变量和DLL链接函数,然后我在程序启动的VC_KTKGK.cpp的文件里添加了读入VCTest.h的语句。然后我在Form1里添加了按钮,在按钮的点击事件里使用VCTest.h文件里声明的链接函数和构造体变量,一切都很正常。然后我在项目里添加了Form2,当我想在Form2里像Form1那样,访问VCTest.h文件里声明的构造体变量时,却发生了变量未定义的错误。 我想知道该怎样做才能在Form2里也能正常访问 VCTest.h文件里声明的变量。   还有,程序执行时,Form2窗体是用Form1的按钮事来打开的,有没有什么需要特别注意的地方。程序代码如下://*******  VCTest.h ********************using namespace System::Runtime::InteropServices;#ifndef _VCTest_H_
#define _VCTest_H_
#define X1OFFSET (0x00)
#define X2OFFSET (0x30)    typedef struct {
long I_ope;
long I_sts;
} GET_OPERATION;typedef struct {
long V_pls;
long V_slp;
long V_ppo;
} SET_POSITIONAL;typedef struct {
unsigned long  V_port;
long V_pl;
long V_bkrsh;
long V_bktmp;
} DLL_OPERATION;typedef struct {
SET_POSITIONAL
SET; 
GET_OPERATION  GET; 
DLL_OPERATION  DLL; 
} AX_AP;AX_AP AA;
AX_AP BB;[DllImport("asXXX.dll")]
extern void AxReSet(AX_AP *p);
[DllImport("asXXX.dll")]
extern void AxInitReSet(AX_AP *p);
#endif//*************************************//********* VC_KTKGK.cpp ****************
#include "stdafx.h"
#include "VCTest.h"
#include "Form1.h"using namespace VC_KTKGK;[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
//Windows XP 效果
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false); // 主窗体做成
Application::Run(gcnew Form1());
return 0;
}//*************************************//*******  Form1.h   按钮事件  **************private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
AxInitReSet(&AA);
}
//*************************************//*******  Form2.h   按钮事件  **************private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 AxInitReSet(&BB); // ******  这一句在编译时出错, 提示 BB变量未定义  ******
}
//*************************************在Form2的按钮点击事件里,不能访问 VCTest 里声明的变量。 想知道怎么办才可以访问。