0 Members and 1 Guest are viewing this topic.
If you are willing to share a debug version, it would be much appreciated!
Can I also know what windows 10 version you are using(use "winver" command)?
Video: https://skrinshoter.ru/vbpWx3anUDr
https://disk.yandex.ru/d/rkuyG5XKbUOZ5Q22H2 (19045.6456)
Another question is about plugin API call, so do I have to call `.AddRef`/`.Release` explicitly for each `IUnknown` instance created/queried?Please see this piece of code in my plugin, it is used to get menu item by ID, (please ignore C++/CLI ^ handles and grammars, they are only managed code), basically it calls `IAIMPServiceMenuManager::GetByID` under the hood, when `IAIMPMenuItem` instance obtained successfully, I wrap it to my `AimpMenuItem` managed class instance and deliver it back to managed code to be used later.At this time, I don't want the `IAIMPMenuItem` instance to be garbage collected or something, so I did not call `->Release` on it, in my option, calling `Release` on an `IUnknown` instance will destroy the instance, am I right or am I wrong? And must I call `.Release` at some point, like when application exiting? Can you try to explain to me? (This may sound stupid to you, apologize for my little knowledge about COM and delphi)
virtual DWORD __unknwncall Release(void) { DWORD reference_count = --counter; if (reference_count == 0) delete this; return reference_count; }
class MyObject: public IUnknown{ IUnknown* ptr; // a raw pointerpublic: MyObject(IUnknown* ptr): ptr(ptr) {} virtual ~MyObject() { if (ptr) ptr->Release; // release raw pointer here // 'cause object doesnt own it anymore }};
IUnknown* service = ... ... service->AddRef(); // u copy the raw pointer // to MyObject object MyObject* obj = new MyObject(service); MyObject->AddRef(); // also increase the // counter of the created object ...
virtual HRESULT Initialize(IAIMPCore* core) { core->AddRef(); // Mistake - Memory leak ... }
DarkDrawKill