C++ Builder

delphi package - easy access to shell apis
Post Reply
AndyBell
Posts: 2
Joined: Tue Apr 07, 2020 2:04 pm

C++ Builder

Post by AndyBell »

Hi

Are there any examples of using MadShell for C++ Builder?

I have no Pascal knowledge and the generated .hpp files aren't making any sense to me...

Andy
madshi
Site Admin
Posts: 10820
Joined: Sun Mar 21, 2004 5:25 pm

Re: C++ Builder

Post by madshi »

Something like this seems to work for me:

Code: Select all

#include "madShell.h"

  _di_IShortCut shortCut = NewShortCut("D:\\Desktop\\test.exe");
  shortCut->WorkingDir = "D:\\Desktop";
  shortCut->ShowCmd    = SW_SHOWMAXIMIZED;
  shortCut->Save("D:\\desktop\\test.lnk");
Generally, madShell uses Delphi type interfaces which are reference counted and automatically freed by the compiler. So you don't have to free/release "shortCut" in the example above, it's done automatically by Delphi/C++.
AndyBell
Posts: 2
Joined: Tue Apr 07, 2020 2:04 pm

Re: C++ Builder

Post by AndyBell »

Hi

Thanks for the tip and sorry for not replying sooner...

Using the LMD shell notify component, I'm getting a PItemIDList for, say, the Drive Add event.

I use this code to get the _di_IIDList:

_di_IIDList list = IDList(aPIDL);

But I can't get any useful info from this. For example, if I try:

_di_IIDList b = list->GetPath();
String c = b->GetStrBuf();

to get some info about the Drive that's been added, variable c is null. The _di_IIDList returned by GetPath(); seems to be a valid object.

The docs on IIDList seem to indicate that GetPath and GetStrBuf should return what I'm after, but I can't make them work...

Andy
madshi
Site Admin
Posts: 10820
Joined: Sun Mar 21, 2004 5:25 pm

Re: C++ Builder

Post by madshi »

Are you sure that the PIDL is both valid and absolute? If it's a relative PIDL, then madShell won't be able to interpret it without having a reference to the "parent folder".

For example, if you were to ask properties about a folder named "Bla", then you would not get any useful results, unless you provide the full path (e.g. "C:\Program Files\Bla"), not just the relative path "Bla".
Post Reply