简体   繁体   English

在 .exe 和 .dll 之间共享变量

[英]Sharing variable between .exe and .dll

I'm creating application that loads external dlls using LoadLibrary().我正在创建使用 LoadLibrary() 加载外部 dll 的应用程序。 Then I load functions and variables by GetProcAddress().然后我通过 GetProcAddress() 加载函数和变量。 Functions are called, variables loaded.调用函数,加载变量。

But I want to make that, for example i have got int which is 5 in DLL, I load it in .exe and in that .exe I set it to 10. But when I cout that int in DLL it says 5 and in .exe it prints 10. So that means that variables aren't shared and i'm just loading values.但我想做到这一点,例如,我在 DLL 中得到了 5 的 int,我将它加载到 .exe 中,然后在该 .exe 中将其设置为 10。但是当我在 DLL 中计算出该 int 时,它说 5 和 in。 exe 它打印 10。所以这意味着变量不共享,我只是加载值。

Does anybody know how can i do that?有人知道我该怎么做吗?

I already found out.我已经发现了。 The problem was that I used ++ operator.问题是我使用了 ++ 运算符。 When i used +=, -=, = it worked fine so the problem is solved.当我使用 +=, -=, = 它工作正常所以问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM