How to get executable directory in .Net

by Matt Gieselman 22. September 2008 05:02

This will give you the current executable directory in .Net:

   System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

  

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Software

How to tell if OS architecture is 64 bit or 32 bit

by Matt Gieselman 20. February 2008 13:01

While working on some installer code I ran into a problem where my C# code was called by msiexec.exe on an x64 operating system.  Msiexec.exe runs as a 32 bit process on 64 bit systems so using (IntPtr.Size == 8) or IsWow64Process won't work, the solution is to use GetSystemWow64Directory, if it returns 0 it fails and you are running on a 32 bit system, if it's non zero you are running on a 64 bit system.

[DllImport("Kernel32.dll")]
public static extern int GetSystemWow64Directory( [MarshalAs(UnmanagedType.LPStr, SizeConst=256)] [In,Out] StringBuilder lpBuffer, [MarshalAs(UnmanagedType.U4)] uint size);

public static bool Is64BitOs()
{
     StringBuilder path = new StringBuilder(256);

     int result = GetSystemWow64Directory(path, (uint)path.Length);    

     return result != 0;
}

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software

Samsung's really bad firmware updater for optical drives

by Matt Gieselman 14. February 2008 08:48
The picture is from Samsung's LiveUpdate Program for Windows that is supposed to download the
latest firmware from their website.  I had it installed on Vista and it worked about as well as the
translation on the right.

If you are a billion dollar company, if you ship hundreds of thousands of optical drives you should
really spend a little extra and splurge on someone to do a better job of translating the text in your
application.  

They should take a look at the Web Updater Garmin uses for their GPS units, it's simple, straight
forward and easy to use.

 

 

 

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Software

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

© Copyright 2009 Matt Gieselman