Archives For VB.NET – General

This is a video showing how I created a program that someone recently requested, hopefully if people find these development diary style videos interesting then I will do more as I make more programs (so please let me know what you think!).

Continue Reading…

For any .NET developers writing programs that require a user to select a container or OU from Active Directory, I’ve made an easy to use dialog window that will show the domain tree and let the user select a specific container.

Continue Reading…

Last year I spent an awful lot of time helping other developers and IT Pros out on vbforums.com, spiceworks.com, Technet forums, MSDN forums, and posting a few things on this blog… but this year haven’t really had that much time to do this – so it was a bit of a surprise to find out I’ve been awarded a Microsoft Community Contributor award for 2011! I’m pleased all the same of course and it is nice to be recognised for helping others. Hopefully my contributions will continue to be useful to other people in the developer/IT Pro community.

Continue Reading…

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.

Continue Reading…

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…

Continue Reading…

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.

Continue Reading…

Just thought I would post about this quickly as its an error message that I ran into recently that took me quite a while to figure out. So to save other .NET developers spending ages trying to work out why it was happening like I did, I’ll explain how you can get rid of this rather annoying problem.

Continue Reading…

Just a quick example of how you can use the System.DirectoryServices.DirectorySearcher class to find deleted objects (that have not yet reached the tombstone time limit) in your Active Directory domain.

Continue Reading…

If you have ever tried to enumerate all groups that a user is a member of in Active Directory then you have probably found that the standard way of doing this (looking at the user’s MemberOf attribute) does not get the user’s primary group. You probably then found out that the user is ‘joined’ to their primary group by simply having the Relative ID (RID) of the group in their PrimaryGroupID attribute. That’s great and all… but how do we translate that RID into the name of the group? Well I’m sure there are a few ways to do it but here’s the code I came up with:

Continue Reading…

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.

Continue Reading…

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.

Continue Reading…

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.

Continue Reading…

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:

Continue Reading…

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).

Continue Reading…

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

Continue Reading…