On Monday, 16 October 2017 at 05:06:26 UTC, evilrat wrote:
On Sunday, 15 October 2017 at 15:13:09 UTC, Nieto wrote:
I'm trying to write a blinding and I found both
IID_ITaskbarList and IID_ITaskbarList2 are defined but
IID_ITaskbarList3 isn't. Any reason why it isn't defined?
sorry if it sounds such a naive question, I'm new to COM and D
interop. I knew a thing or two about PInvokes with C#.
Then how do I define it myself?
I've tried this:
GUID IID_ITaskbarList3 =
createGUIDFromString("{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}");
GUID createGUIDFromString(string guidStr) {
GUID guid;
wchar* GUID_STR = toUTFz!(wchar*)(guidStr);
HRESULT hr = IIDFromString(GUID_STR, &guid);
assert(SUCCEEDED(hr));
return guid;
}
I'm unsure if it's the proper way to do it (if not, please
show me the right one)
But the call to CoCreateInstance() still fails to access any
member of m_pITaskBarList3 object, so I'm making sure I'm
passing the correct arguments to the function. The memory
access error is:
object.Error@(0): Access Violation
HRESULT hr = CoCreateInstance(&CLSID_TaskbarList, null,
CLSCTX_INPROC_SERVER, &IID_ITaskbarList3,
cast(void **) &m_pITaskBarList3);
assert(hr == S_OK);
The assert() doesn't run, so the error is somewhere else... I
guess.
Did you call CoInitialize before creating anything? Is your
ITaskbarList3 defined as interface?
Here is the simple example anyway
https://gist.github.com/Superbelko/277d86a17d497eae85a7f1788bfd83b4
There are no predefined GUID's and declarations for some stuff
because standard WinAPI bindings is incomplete, you can
probably contribute and add some
https://github.com/dlang/druntime
Yes, I did call CoInitialize(null) before call CoCreateInstance().
I thoguht the GUID was some kind of constant value to identify
the ITaskbarList3 (the struct name is even IID). I was dead wrong
lol but I was just starting with the COM world. I defined
CLSID_ITaskbarList3 like your IID_ITaskbarList3. I realized my
mistake: out of C++ habit, I declared the ITaskbarList3 as a
pointer! That's why it wasn't working. I didn't realized it until
I read your code. Again, thank you very much. I'll try contibute
to the WinAPI binding once mine is complete.
Have a nice day! :)