Well, if your goal is to embed the client identifier (email address, code, etc.) in exe, the easiest way I can think with is IPropertyStorage and IPropertySetStorage . If you feel brave, you can call the methods directly on IPropertySetStorage via p / invoke , or you could take the easy route and use the Microsoft-prepared COM shell called dsofile.dll .
Please note that while dsofile is for office documents, it really works with any file - including .exe files - you are just stuck with predefined property names. Why not throw your customer id into something like the .Comments property. Just do it so that you can take it apart again.
Here is an example:
var doc = new OleDocumentPropertiesClass(); doc.Open(pathToFile); doc.SummaryProperties.Comments = " joe@test.com "; doc.Save();
Of course, you need to first copy it to a temporary location, and some time after downloading it, you will want to delete it.
You can associate dsofile.dll with your application and register it as a dependency and use it in your installer to read the property back. Or, if you can p / call IPropertyStorage without it, then you will not have a dependency.
Another thing to learn is to use the advanced file properties that Shell32.dll reads. I just couldn't find an easy way to write them easily. If you go this route, share how you wrote the properties in your .exe.
source share