For this proof of concept, I wrote DLL in C++ that uses the Windows subsystem to search a users applications for a keyword. Inside Unity, I created a script that would load and call into this DLL with simple designer friendly interface that allows a chunk of dialogue to be spoken if a matching word is found.
The C++ source code is available here
Put together in this demo, we see a clerk that mocks or praises the player based on their choice in games , a la 'Psycho Mantis' in the classic Metal Gear Solid boss battle.
How I did it
Windows has a virtual folder containing all executables on the drive (you can see your's by hitting Win + R and entering 'shell:appsFolder'), which the DLL enumerates using a COM object. The C++ interprets a string from Unity as a char* which I first cast as a std::string before forcing all the characters to lowercase for better comparison.
The display name extracted from the apps folder are returned as an obscure struct containing a union that must be passed to an additional function to extract the string.
It then tries to find the specified word within that display name (not necessarily an exact match) and will return a 1 if found. I return an integer instead of a boolean to make the code easier to manage, as booleans would require additional marshaling.
What for?
Creating a 'Native' DLL that Unity can call into requires some manual setup to allow the C++ functions to be stored in the the export table, and additional targeting in the C# script, but the end result is often more performant code and in this case access to some of the more obscure Windows API functionality.
A potential commercial use of this would be to gather some metric on the players taste based on installed games and tailor an experience based on that. 
Back to Top