torsten's .NET blog In the end, everything is a gag [Ch. Chaplin]
# Friday, October 19, 2007
Get the local mapped network drives using WMI

Today I helped a coworker to get the local mapped network drives using WMI instead of COM Interop/native windows API. Just to keep the code as a reminder and help others with the same problem I provide it here.

The result of the code below is in general the same you will get if you hit the "net use" command at the windows command shell prompt. For further infos and reading I suggest http://msdn2.microsoft.com/en-us/library/aa394173.aspx (Win32_LogicalDisk; MSDN WMI Reference); for immediate results of query the WMI you should use Scriptomatic (download from http://www.microsoft.com/downloads/details.aspx?familyid=09DFC342-648B-4119-B7EB-783B0F7D1178&displaylang=en).

Little bit optimization is yet possible providing the drive type in the WQL as a where clause parameter, so here it is:

/// <summary>
/// Container for Share entries
/// </summary>
public struct SharePathEntry
{
  public string Name;
  public string Path;
  public SharePathEntry(string n, string p) {
    Name = n;
    Path = p;
  }
}

// for other types see: http://msdn2.microsoft.com/en-us/library/aa394173.aspx
const int NetworkDriveType = 4;

public static List<SharePathEntry> GetLocalShares()
{
  List<SharePathEntry> allLocalShares = new List<SharePathEntry>(); // a container

  WqlObjectQuery objectQuery = new WqlObjectQuery("select DriveType,DeviceID,ProviderName from Win32_LogicalDisk");
  ManagementScope scope = new ManagementScope(@"\\.\root\cimv2"); // local WMI namespace
  scope.Options.Impersonation = ImpersonationLevel.Impersonate;
  scope.Options.EnablePrivileges = true;
  ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, objectQuery);
  foreach (ManagementObject share in searcher.Get())
  {
    int driveType = Convert.ToInt32(share["DriveType"]);
    if (driveType == NetworkDriveType) {
      object objName = share["DeviceID"];
      object objPath = share["ProviderName"];
      if (null != objName && null != objPath)
      {
        allLocalShares.Add(new SharePathEntry(objName.ToString(), objPath.ToString()));
      }
    }
  }
  return allLocalShares;
}
Technorati tags:  |  | 
Friday, October 19, 2007 10:02:12 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Thursday, September 20, 2007
Project source browsing with FishEye

You may have noticed we released v1.5.0.17 of my favorite feed reader (and refreshed the installer meanwhile) - for the coding guys we now have even more: Project Supported by FishEye

Thanks to the folks at atlassian we are now have the comfortable source browsing tool running on the SF repositories (CVS with the CLR 1.1 code and SVN for CLR 2.0). Most I like the diffs view and RSS link in the top right - there the circle closes (subscribed).

Technorati tags:  |  | 
Thursday, September 20, 2007 7:23:26 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Tuesday, September 19, 2006
BASTA! 2006

I'm now again at BASTA! 2006, Mainz - Germany. Had alreda some interesting discussions here with some of the speakers, also the SOA architecture day yesterday was very interesting. Lesson learned: SOA is not really new, and it is not a technology. Just a idea to live.

Most interesting session today was about advanced debugging, by Ingo Rammer. He introduced some tools I never heard of and pointed out how to catch the most often issues debugging is used for, such as memory leaks in Windows Forms applications, or how to debug a CLR windows service. We had look inside WinDbg - what a cryptic tool, just remembered my time using the vi/unix years ago...

Most impressive was the keynote by Jason Zanders the "father of .NET Framework 3.0" today: about .NET Framework 3.0 and Vista. Live programming on Vista (RC) in Python using CLR 3.0, WPF and speech support (build in in CLR 3.0). Just one issue: the presentation machine with the slides just stopped working and required a (live) reboot. Lesson to learn: don't use beta software to just show slides ;-)

Technorati tags:  |  |  | 
Tuesday, September 19, 2006 1:02:16 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Thursday, April 20, 2006
Must read: Version Control with Subversion

Note to myself: must read http://svnbook.red-bean.com/en/1.1/svn-book.html if I got more than 15 minutes (coding-)free time.

Technorati tags:  |  | 
Thursday, April 20, 2006 9:19:38 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [4]  | 
# Saturday, March 25, 2006
Update: DiffPatchResources creates .strings file(s)

As I yet posted this is a little tool to help with common tasks to maintain resource files. Recently I started to use the famous StringResourceTool MS used within the Enterprise Library and it is way cool! Worth to have a look if you start a new project from scratch.
But stop! You can now migrate existing project(s) to use the the StringResourceTool by the little help of the DiffPatchResources tool! Just download and copy it to a folder you configured to be found if you start a windows command line (%PATH% variable). Then use the new option -s to create the .strings file out of your existing main .resx file and save all the hand writings...

Update: to get the StringResourceTool run in VSIDE 8.0, add these settings to your registry by help of a .reg file with content:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Generators\{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}\StringResourceTool]
"CLSID"="{1D47CA76-5AF1-4152-8106-08140FF9886E}"
"GeneratesDesignTimeSource"=dword:00000001
@="Microsoft Data Warehouse String Resource Generator"

Technorati tags:  | 
Saturday, March 25, 2006 5:12:31 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [3]  | 
# Friday, March 03, 2006
Enterprise Library - Syslog Sink Extension available for download
My user sample related to the Enterprise Library is now up and available for download. It extends the logging by providing a sink that is able to log to a syslog daemon (some of you may know that from UNIX systems). It works  according to the definitions in RFC 3164 (http://www.faqs.org/rfcs/rfc3164.html) writing log entries to UDP port 514. Not yet optimized for speed and no EntLib Configuration Console support, but a starting point. Binaries, a short documentation and source can you find here.
Technorati tags:  | 
Friday, March 03, 2006 3:28:14 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [1]  | 
# Tuesday, October 25, 2005
1.3.0.36 Alpha and AdsBlocker HowTo

We decided to post another iteration of the Rss Bandit Alpha (v1.3.0.36): read about the details at Dare Obasanjo's blog and download it here.

It is the first version that is AddIn - enabled and you can find and use the first AddIn available here: AdsBlocker. So how to use it?

  1. Download and unzip to a folder you like (e.g. "AddIns" sub-folder within your Bandit installation path).
  2. Start Bandit and open the AddIns dialog via Tools|AddIns... menu.
  3. Press the "Add..." button and select the AdsBlocker.AddIn.dll
  4. Press "Close"
  5. Optional: add entries/modify the ads.blacklist.txt file (regular expressions) to configure your blocked content (urls)
  6. Optional: create a white list "ads.whitelist.txt" in the same location if your blacklist gets large and you want to re-enable some blocked content.

 

Technorati tags:  |  |  | 
Tuesday, October 25, 2005 6:59:45 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [4]  | 
# Friday, September 02, 2005
"Send to OneNote..." plugin for RSS Bandit
Just got it work, yesss! You can download it here. Just expand the zip to your RSS Bandit installation sub-folder named plugins. Within the config file you can change the default note page used and some templates to format the posted item link and content.
Inspired by a comment by MrPuck at Dare Obasanjo's post I got the idea. It should work with OneNote 2003 SP1. Thanks to Donovan and Andrew.
Technorati tags:  |  |  | 
Friday, September 02, 2005 8:11:06 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [2]  | 
# Tuesday, May 31, 2005
Cool shell extension for .NET assemblies
Back from vacations today I found the article Shell Extensions for .NET Assemblies at codeproject.com: really useful tool (must have) to get our projects organized (old VB6 stuff vs. newer .NET stuff). It visually distinguish between normal windows DLL's and .NET assemblies and shows if the assembly is signed via a public key token column.
Technorati tags:  |  |  | 
Tuesday, May 31, 2005 10:20:00 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [4]  | 
# Tuesday, May 03, 2005
Very useful: single sign-on simplified
Technorati tags:  |  | 
Tuesday, May 03, 2005 8:07:00 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [1]  | 
Serious issues in .NET that may affect my work

Today there was a flood of fixed isses (12) for .NET 1.1 published via the Most Recent KB for MS .NET Framework 1.1 article feed. Some that that may affect me at work are

Is there any deadline known for SP2?

Technorati tags:  |  | 
Tuesday, May 03, 2005 7:21:17 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Tuesday, February 22, 2005
Keep them synchronized!

Today I wrote a little tool to keep the various language resource files of VS7 projects synchronized: you know usually you have to add a new resource string to all the language files as you need a new one. But I think I'm not the only one: I'm lazy to maintain them all the time I need a new entry :-( Especially if you have more than a hand full of language specific .resx files. So here it is:

http://www.rendelmann.info/packages/DiffPatchResources.zip

From the readme:

A small console application to keep VS7 .resx files in sync. with the main resource.

It expect the path and filename to the main text resource file (.resx, no language LCID) as a command line parameter, so you can simply drag/drop the main resource file to the executable file, e.g.:

 DiffPatchResources.exe "C:\MyProjects\MyApp\Resources\mainText.resx"

It will iterate the "/root/data" entries in the main file (e.g. main.resx) and
patch each dependent language file (mainText.[LCID].resx) to contain any missing entry. Further, if the source data contains a comment element and the content of that starts with "CHANGED" text, it will replace the yet existing target entry with the changed entry of the source.

It writes a .bak file on each modified resource and reports success/failures and some statistics to the console.

========= ATTENTION! =============

Currently it does NOT work on .resx files related to Forms! You should not try to get it run on such files! I will not guarantee for any success and will not be responsible for any damage resulting of the any usage of this tool!

For any improvements or comments leave a comment here, please. Have fun!

Technorati tags:  | 
Tuesday, February 22, 2005 12:13:53 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
Navigation

Like RSS Bandit? Make a donation to help support its development and maintenance. As little as 1€ will help.

Make payments with PayPal - it's fast, free and secure!
On this page....
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

SUBSCRIBE RSS GeoURL e-mail

Search
Categories
Blogroll
[Feed] Dare Obasanjo
Dare Obasanjo aka Carnage4Life
[Feed] Clemens Vasters
[Feed] Omar Shahine
[Feed] Tom Mertens

newtelligence dasBlog 2.1.8102.813

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

WOT Notar

Join WebHost4Life.com