public Accelerometer() { RegistryKey tAcelMgrKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\TOSHIBA\\AcelUtil\\TAcelMgr"); string path = (string)tAcelMgrKey.GetValue("PATH"); tAcelMgrLibrary = NativeMethods.LoadLibrary(path); IntPtr getImmediateFunction = NativeMethods.GetProcAddress(tAcelMgrLibrary, "GetImmediate"); getImmediate = (GetImmediate)Marshal.GetDelegateForFunctionPointer(getImmediateFunction, typeof(GetImmediate)); IntPtr getZeroBaseFunction = NativeMethods.GetProcAddress(tAcelMgrLibrary, "GetZeroBase"); getZeroBase = (GetZeroBase)Marshal.GetDelegateForFunctionPointer(getZeroBaseFunction, typeof(GetZeroBase)); getZeroBase(out xMin, out yMin, out xMax, out yMax); XLength = (short)(XMax - XMin); YLength = (short)(YMax - YMin); }