GetModuleFileName() 개인적인 메소드

private GetModuleFileName ( [ hModule, [ lpFilename, [ nSize ) : uint
hModule [
lpFilename [
nSize [
리턴 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);
        }