summaryrefslogtreecommitdiff
path: root/src/api/burn/WixToolset.Mba.Core/NativeMethods.cs
blob: 45a0bc4d79ee0c54d0ad72f34ca51014249bd8fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixToolset.Mba.Core
{
    using System;
    using System.Runtime.InteropServices;

    /// <summary>
    /// Contains native constants, functions, and structures for this assembly.
    /// </summary>
    internal static class NativeMethods
    {
        #region Error Constants
        internal const int S_OK = 0;
        internal const int E_MOREDATA = unchecked((int)0x800700ea);
        internal const int E_INSUFFICIENT_BUFFER = unchecked((int)0x8007007a);
        internal const int E_CANCELLED = unchecked((int)0x800704c7);
        internal const int E_ALREADYINITIALIZED = unchecked((int)0x800704df);
        internal const int E_NOTFOUND = unchecked((int)0x80070490);
        internal const int E_NOTIMPL = unchecked((int)0x80004001);
        internal const int E_UNEXPECTED = unchecked((int)0x8000ffff);
        #endregion

        #region Functions
        [DllImport("shell32.dll", ExactSpelling = true, SetLastError = true)]
        internal static extern IntPtr CommandLineToArgvW(
            [MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine,
            out int pNumArgs
            );

        [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
        internal static extern IntPtr LocalFree(
            IntPtr hMem
            );
        #endregion
    }

    #region SafeHandles
    internal abstract class SafeHandleZeroIsDefaultAndInvalid : SafeHandle
    {
        public SafeHandleZeroIsDefaultAndInvalid() : base(IntPtr.Zero, true) { }

        public override bool IsInvalid
        {
            get { return this.handle == IntPtr.Zero; }
        }
    }
    #endregion
}