【发布时间】:2018-06-06 09:52:40
【问题描述】:
我正在尝试使用WM_COPYDATA 在两个程序之间发送数据,但COPYDATASTRUCT 的定义有问题;
这是错误:
代码如下:
#include <iostream>
#include <Windows.h>
#include <string>
#include <stdio.h>
#include <tchar.h>
#include < stdlib.h >
#include < vcclr.h >
#include <msclr\marshal.h>
#include "MyForm.h"
namespace TestGraphique {
using namespace System;
using namespace msclr::interop;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Xml;
using namespace std;
typedef struct tagCOPYDATASTRUCT {
ULONG_PTR dwData;
DWORD cbData;
PVOID lpData;
} COPYDATASTRUCT;
/// <summary>
/// Description résumée de MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
typedef struct COPYDATASTRUCT cpd;
cpd.dwData = 0; // there is the problem
cpd.cbData = dataToSend.GetLength(); // there is the problem
LPTSTR pszMem = new TCHAR[10000];
HWND hWnd;
HWND hWnd1;
HWND hWnd2;
HWND hWnd3;
String^ a = "";
String^ b = "";
String^ c = "";
String^ d = "";
String^ result="";
String^ TABLE = "";
MyForm(void)
{
InitializeComponent();
}
【问题讨论】:
-
请将完整的错误消息以文本形式发布。只是一张带有红色下划线文字的图片不会给你答案。
-
其实先搜索那个错误文本。几乎肯定有一个现成的答案。
-
有错误对不起它在法语中:“
un membre d'une classe managé ne peut pas être d'un type de classe non managé”它在 COPYDATASTRUCT cpd 行中; cpd.dwData = 0; cpd.cbData = dataToSend.GetLength(); -
"
un member d'une classe managé ne peut pas être d'un type de classe non managé" :a member of a managed class can not be of an unmanaged class type -
包括
<windows.h>应该可以解决这个问题
标签: c++ string sendmessage wm-copydata