Click here to Skip to main content
15,880,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use isf (type: IShellFolder* defined in ShlObjDl_Core.h) to use ParseDisplayName because it's a nonstatic member of IShellFolder, so it must be relative to a specific object.
But, when I use that code:
C++
IShellFolder* isf;
LPITEMIDLIST lprnt = { 0 };
ULONG lngth;
isf->ParseDisplayName(hWnd, NULL, (LPWSTR)"C:", &lngth, &lprnt, NULL);

I get:
Exception thrown: read access violation. isf was nullptr.

What I'm doing wrong?

What I have tried:

I've tried:
1- adding * to IShellFolder* to become IShellFolder** but it didn't work.

And this question isn't like the previous question (about a function getting a structure passed at one of its arguments) but it is about a reference from an variable for a function.
Posted
Updated 1-Apr-23 22:10pm

Similar to your previous question at I get always an error "exception thrown: write access violation. Lpsh was nullptr."[^]. But in this case you create a pointer but you do not initialise it to point to anything. If you do not understand pointers and references then go back to your C reference for guidance.
For an example of using the IShellFolder interface see Getting Information About the Contents of a Folder - Win32 apps | Microsoft Learn[^].

[edit]
Also the following is incorrect in the call to ParseDisplayName;
C++
(LPWSTR)"C:"

You cannot use a cast to convert an ASCII string to Unicode. You need to generate the Unicode characters at compile time by using the L prefix to the string, thus:
C++
L"C:"

[/edit]
 
Share this answer
 
v2
As Richard already wrote, you are missing some basics. To kickstart read the Microsoft documentation.

Such stuff isnt a walk in the park, so you must understand the complex topic. Good luck.

Here is some interesting stuff on github. When reading that well written article you get a taste about the complexity of COM.

additional tip: in C# the most of that boring stuff is handled under the hood.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900