So basically, I'm trying to read a log file from a game while that game is running in order to have my program react to it in dynamic ways. I know it's possible, as other programs such as Notepad(++) are able to do it. However, after searching for an answer, most of what I can come up with is only Linux related.
I have no idea as to how to go about this, help in doing so with either C++ or C# would be great. Even though I would prefer native C++ over C#.
The "native" winapi solution is CreateFile, and in particular its dwShareMode parameter.
Related
I need to be able to check who has a file open using C#. I found a few people asked this question before but they were all a long time ago with the latest being in 2012. I was wondering if, in the last 5 years, has Microsoft added this ability to .net or maybe someone came out with a nuget package that is capable.
Here is the latest answer I found
You can use windows internal function NTQuerySystemInformation with undocumented parameter SystemHandleInformation for it. I don't know about c# implementation, but I know delphy code for it, and vb6 code. Check this links, it will help you to make your c# implementation.
Delphi - get what files are opened by an application
https://forum.sysinternals.com/topic14546.html
As far as I know, the standard library still does not have suitable functions for this. There is a popular question about this: https://stackoverflow.com/a/937558/5665527.
Also, if you want to know who opened the file remotely - net file function may be useful (which is accessible via cmd). I believe that there are similar WinAPI functions on MSDN that could be implemented in a similar way.
i would like to know weather it is possible to control some wpf application written in c# by using a c# dll out of matlab.
what i need is the possibility to start the MainWindow and i have to be able
to get some values into my controller.
What i found so far was things working from c# that use matlab, but the other way round seems not to be that much populatet, as i found nothing i could really use.
I allready tried to import a .net Library, but i dont seem to be able to open a external class from my dll.
So if you could help me on this it would be great.
Regards,
justSomeone
Ok, i did just find out, that i can also import my .exe file into Matlab instead of only dlls .
I am using the function NET.addAssebly('Path.exe') to do this.
Path.exe is just a symbol that it is directed to the place of the .exe file.
I achieved to be able to use my methods as i wanted i do have my instance of the class. So i am happy now. :D
But if you have other solutions which are more handy, dont hesitate to post them. There might still be interesting things to discover :)
Regards,
justSomeone
Was wondering if anyone would be so kind to point me in the right direction on how to call a third party's C++ DLL in C#. The API is closed source but the header files are available.
I've read up on using P/Invoke but after further diving, it's leading to marshalling very complex data structures across, and that's IF I can do the declarations for the third party classes/functions.
If there's any reading material / tutorials out there you can recommend or just point me in the right direction, I would appreciate it.
Thanks so much in advance
I found http://www.pinvoke.net/ to be very helpful.
Also the http://clrinterop.codeplex.com/releases/view/14120
Additionally, what I did that I found helpful was to do a test solution. Start off with making a C# console app that initially does nothing, then make another Project (File, New, Project, Visual C++, Win32 Console Application)
When the Wizard appears, choose DLL, Export symbols, (ATL and/or MFC if you need that).
When the Project appears, compile it as is and copy the DLL to you output folder of you C# Project
Use the P/Invoke Interop Assistant to generate the C# method based on the header (I'd start with the function that takes no params and returns an int.)
then call that from your C# console app.
Once I'd established how it worked with something really simple it was much easier to expand a bit at a time.
Try writing the C# calls yourself and then use the P/Invoke Interop Assistant to double check. Best wishes.
I made a browser program for a archive type with the .mpq extension, which is highly used in Blizzard games.
It is like an explorer but only explores files inside MPQ archives.
Now, we all know how Windows Explorer browses .zip archives and I'd love to make it open the .MPQ files with so many rich features.
Is this even possible? So it is possible...
If so, then how? Shell Folder...
Can someone please point me to an example? (C#) I can't just translate C++ to C#...
This is done via extending the shell classes. You'll need to implement the Basic Folder Object Interfaces to accomplish this.
Although it is a C++ framework, there is a framework that implements exactly what you want, and that I have adapted with success for a similar file format:
TarFolder (by the guy who developed GMail Drive).
You may also be interested in EZNamespaceExtension.Net, even if they do not support extension-based rooting (a workaround is to use URLs with specific protocols).
Finally, check out WindowsShell: it might be exactly what you are looking for !
Sorry for coming so late after the storm...
I browsed internet but haven't found my answer... as I'm running out of ideas, I'd appreciate some help on this issue.
So here it is:
I have some PHP code that takes a path to a file and returns a bunch of information that i need.
I have the source code (it is open source), and i know my C#.
My problem is i want to be able to use this PHP code from a C# application, offline, emulating the PHP code.
Any ideas?
Thanks.
If you really must, you can always launch the PHP interpreter from C# by spawning a process. I'll leave the details to MSDN. Better, though, would be to just translate the PHP to C# by hand.
You could set up a PHP server on the local machine and invoke the file using an HTTP request created with c# (such as with the WebRequest object). This satisfies the requirement of working offline and since you have the PHP code, you can make minor modifications to accommodate whatever parameters you need to pass into it.
However unless this is for an isolated case in a controlled environment, I would not suggest it.
If this is for distribution to user machines it would be a) impractical to deploy and b) a maintenance nightmare. If you are running on a server and rewriting the PHP in c# is not an option, it should get the job done.
It sounds like to either wish to
Translate the PHP code to C#
Call the PHP code from .NET
???
I don't think emulation is the term you're looking for, exactly.
If you can link to the PHP code (if it's OSS, is there a site with more information?) or paste it here, we can probably let you know the best way to handle this.
If you don't want to translate the PHP code into C# then you must invoke the PHP interpreter.
First, look at the license on the PHP code you would be using. When I looked at the code earlier I noticed that all but one PHP file had a GNU GPL license on it. GNU GPL should work for what you want, but I recommend that you review the GNU GPL if you haven't done so already. You should also look into what license is supposed to be applied to the last file before continuing.
Second, rewrite the entry file. The file in question is upload_file.php. This file loads the other files as includes, parses the SC2 replay file, and generates an output for use by a web browser. You just need to rewrite this file to have it output a simplified version of its output to the console. You might have it receive the name of the replay file from command line arguments. The other files that are marked as GNU GPL can just be copied directly into your project. I should also say here that there may already be a console version. Take a minute to look around for one.
Third, write a C# application. Invoke the PHP interpreter telling it the what file to interpret, and the name of the replay file to parse. You will need to redirect the console output from your PHP instance into your C# code to be able to read the output.
Fourth, read the output.
Fifth, parse the output for use in your C# application.
Old thread but figured it could use an answer.
You could use the codeplex Phalanger. http://phalanger.codeplex.com/ It allows you to take existing php files and compile them to .net