1

我正在尝试编写一些插件以与 MIDI 音序器一起使用,但遇到了一个绊脚石。我不能使用全局范围的变量来存储信息,因为可以存在多个共享内存的 .dll 实例。

如何创建一个包含二维数组和其他变量的类(出于其他插件的重用目的),其内容将在函数之间共享?如果可能的话,我将如何从我进行处理的框架中的函数读取和写入数据?

4

3 回答 3

1

What do you mean by "multiple instances of the DLL"? In Win32, every process has its own private address space, and DLLs with global variables are specific to that process. A DLL cannot be loaded more than once into the same process.

In the bad old days of Win16, DLL global variable space was shared between processes, which led to no end of headaches.

于 2011-01-06T03:50:23.083 回答
0

事实证明,这是一个 C++ 处女错误,我咳嗽只需要在插件类的咳嗽类声明中声明必要的变量。

感谢大家的帮助。我很可能会带着关于如何从具有各种古怪指针和东西作为参数的类中获取信息的问题回来。

敬请关注!:)

于 2011-01-06T11:43:54.857 回答
0

您在寻找static关键字吗?

static int i = 1; //this keeps its value at each call
于 2011-01-06T03:45:26.020 回答