Closed arlm closed 8 years ago
Except for the IntPtr
-> pointer the rest LGTM
Why is your src/Shell32.Desktop/Shell32.exports.txt
file empty? It should have a bunch of function names in it. The AddNewLibrary.ps1
script generally takes care of this for you. Did it malfunction?
Could you perhaps try directly running CreateExportsTxtFile.ps1
to see if it can create it properly?
Strange. It seems that it failed. But the AddNewLibrary run.
File C:...\pinvoke\templates\CreateExportsTxtFile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
Is there any other way to populate it?
You could run this powershell command to unblock it, I think:
set-executionpolicy remotesigned
I'm working on this PR now to resolve some issues we've talked about.
Also, the ILFree
method is missing, which evidently is a requirement when anyone calls SHGetKnownFolderIDList
Well, I've come away convinced that pointers were definitely important to retain here. The rules for these functions and how to free the memory they allocate are diverse, and there's no way the .NET Marshaler could handle it all automatically. It must be done with native pointers (or IntPtr) rather than marshaled so that the original pointer is available to free later. Helper methods can help keep things sane for the caller though. I'm pretty sure there were memory leaks in the original PR.
SetLastError=true
is inappropriate, because these functions don't document to use it.
Also you seem to be treating error codes as if they were Win32 errors by throwing Win32Exception
, which is inappropriate because these functions return HRESULTs.
@vbfox please consider looking at arlm/pinvoke#2 to review the changes I'm proposing to this PR.
But before we can merge this PR, #248 needs to be fixed to avoid introducing a bunch of build warnings.
@AArnott arlm/pinvoke#2 LGTM, nice that we can have tests for that. I don't know if the manual methods to change / get the value under an SHITEMID
will be useful to anyone but the code LGTM.
(Make me think that I could create a NuGet version of my answer on how to open explorer with files selected http://stackoverflow.com/a/3578581/46594 now that we are adding shell functions)
Thanks.
Yes, I meant to add tests for my SHITEMID
accessor methods. But I also found in debugging that the buffer appears to not be intended for direct consumption, so I can probably just remove them all.
I've removed the accessor methods and added doc comments warnings folks to always use pointers (or IntPtr) when handling these structs.
Thanks for your contribution, @arlm!
I added KnowFolders related funcitions and constants