GetModuleFileName() private method

private GetModuleFileName ( [ hModule, [ lpFilename, [ nSize ) : uint
hModule [
lpFilename [
nSize [
return uint
示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Win32ProcessIDHelper" /> class.
        /// </summary>
        public Win32ProcessIDHelper()
        {
            _currentProcessId = NativeMethods.GetCurrentProcessId();

            var sb = new StringBuilder(512);

            if (0 == NativeMethods.GetModuleFileName(IntPtr.Zero, sb, sb.Capacity))
            {
                throw new InvalidOperationException("Cannot determine program name.");
            }

            _currentProcessFilePath = sb.ToString();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Win32ThreadIDHelper" /> class.
        /// </summary>
        public Win32ThreadIDHelper()
        {
            this.currentProcessID = NativeMethods.GetCurrentProcessId();

            var sb = new StringBuilder(512);

            if (0 == NativeMethods.GetModuleFileName(IntPtr.Zero, sb, sb.Capacity))
            {
                throw new InvalidOperationException("Cannot determine program name.");
            }

            this.currentProcessName     = sb.ToString();
            this.currentProcessBaseName = Path.GetFileNameWithoutExtension(this.currentProcessName);
        }