Using .NET you may think that determining which permissions are assigned to a directory/file should be quite easy, as there is a FileSystemRights Enum defined that seems to contain every possible permission that a file/directory can have and calling AccessRule.FileSystemRights returns a combination of these values. However, you will soon come across some permissions where the value in this property does not match any of the values in the FileSystemRights Enum.
Archives For VB.NET – Windows API
Useful Windows APIs that I have used in VB.NET
When deploying a package that installs fonts (a simple MSI installation in our case) via SCCM, the user that is logged on to the computer when the MSI is installed will not be able to use these new fonts until they log out and log back on. Read on for my explanation and solution…
There are not that many changes in this release as I was only updating it for my own use really but I figured other people may benefit from the new API definitions and managed methods included.
Launching a process that the currently logged on user can see on their desktop session (and interact with) from a Windows service is a popular topic – and there are a wide variety of answers out there when someone asks how to do this, some people say it is not even possible on Windows Vista or Windows 7. Turns out it is actually very easy…
I’ve been trying to find a way to script or automate the creation of a new Windows VPN connection that uses L2TP/IPSEC with a pre shared key and automatically uses the current user’s credentials, but it seems there is no way to do this using the CMAK, netsh, various powershell scripts, or GPO Preferences as none of them include all of the options we needed to set. So I have come up with a .NET app for doing this and am posting the code here in case it helps anyone else out.
Well getting the power scheme APIs working on Windows 7 and Vista is taking a little longer than expected so I thought I would bring this new version out without the power related methods so that people can use the other new methods sooner rather than later. Download link for new version is at the end of this post, but I encourage you to read the full post to see what has changed in this version.
Even though I only released my .NET Windows API library (Cjwdev.WindowsAPI) quite recently, I’m planning to release a new version pretty soon as there are still plenty of things I want to add to it. EDIT: New version is now available, see this post. I will be releasing updated versions fairly often rather than waiting until I have a large amount of new methods etc, so keep checking back on this blog for updates. This post describes the new methods and classes that I have added (or am planning to add) to the next release, along with the Windows APIs that the managed methods use. As always, let me know if there are any particular APIs you would like to see in here and I will try and get them in.
This is the first official release of my .NET Windows API pack – a class library that is intended to make it easier to work with several native Windows APIs from managed .NET code. There are over 50 Windows APIs defined in this library and roughly 30 managed methods that use these APIs to provide functionality that is not available in the .NET Framework today. Many more will be included in the next version but hopefully this first version will still be useful to a lot of people.
I have nearly finished the first release of my Windows API pack, which is a class library (DLL) that makes using certain Windows APIs from .NET code easier and simpler. You just add a reference to this class library and then you can call managed .NET methods from the library rather than having to figure out how to use the Windows APIs yourself. So far I have got just over 25 managed methods in this library, which makes use of roughly 45 Windows APIs. You can see a list of my managed methods and a description for each one below:
I’ll start off by saying that there is not much use for this because ordinarily you would use the .NET Framework’s built in Process class, but there are some rare scenarios where that is not possible so hopefully this will help some of you in that situation out. Basically this is a small vb.net app that demonstrates how to redirect the input and output of a console application that you have launched via the CreateProcess API (or CreateProcessAsUser etc).
I wrote this code primarily to be able to get the windows services running in each svchost.exe process, however it can be used against any process to see which services (if any) are running within it. It makes use of the EnumServicesStatusEx, OpenSCManager, and CloseServiceHandle Windows APIs. If you are not a developer and just want to see which services are in an svchost.exe process, see this post
I recently needed to get the command line arguments that an external process was started with (one that was not started by my application, svchost.exe to be specific) and found that the only way I could get this information was with Windows APIs. The API in question just returned pointers that references locations in the memory of the external process (which meant I could not use the .NET Marshal methods as they would treat the pointers as references to my own process’s memory – thanks to wj32 for helping me understand that) so I had to use the Windows API ReadProcessMemory. I will be posting my full example of how to get the command line parameters for an external process soon but for now I thought I would just post this .NET class I wrote that makes reading process memory a bit easier as it does all of the API work for you.
Here’s yet another .NET wrapper/helper that I’ve written for some Windows API functionality. This time my code makes use of about 6 different Windows APIs to provide you with a method that will return a list of all windows that are currently open on the computer along with their handle, title bar text, class name and the process that owns the window.
Also might be worth mentioning: I’m going to be releasing a class library soon full of lots of these “.NET friendly” methods that I’ve written to make calling specific Windows APIs simpler and easier. So you can just add a reference to the class library DLL and then you can avoid having to use the APIs directly as you can just use my nice simple .NET methods, with no need to marshal anything across to unmanaged code. Check back on this blog soon if that sounds like something you would be interested in.