-3

我正在尝试在两个程序之间发送数据,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();

    }
4

1 回答 1

0

有几个问题:

您正在定义一个类型,而不是创建一个变量。将行更改typedef struct COPYDATASTRUCT cpd;COPYDATASTRUCT cpd;

您不能在类定义中执行代码。您应该将这些行移动到一个函数中:

cpd.dwData = 0;
cpd.cbData = dataToSend.GetLength();

你不需要COPYDATASTRUCT在你的程序中定义。它在 windows.h 中定义。删除这个:

typedef struct tagCOPYDATASTRUCT {
    ULONG_PTR dwData;
    DWORD     cbData;
    PVOID     lpData;
} COPYDATASTRUCT;
于 2018-06-06T12:03:07.090 回答