Utils.cs :  » Network-Clients » iReaper » IReaper » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » iReaper 
iReaper » IReaper » Utils.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32.SafeHandles;
using System.Threading;
using System.Runtime.InteropServices;

namespace IReaper{
    /// <summary>
    /// 2Win32
    /// </summary>
    public class Utils
    {
        #region const
        public const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000;
        public const UInt32 SECTION_QUERY = 0x0001;
        public const UInt32 SECTION_MAP_WRITE = 0x0002;
        public const UInt32 SECTION_MAP_READ = 0x0004;
        public const UInt32 SECTION_MAP_EXECUTE = 0x0008;
        public const UInt32 SECTION_EXTEND_SIZE = 0x0010;
        public const UInt32 SECTION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
            SECTION_MAP_WRITE |
            SECTION_MAP_READ |
            SECTION_MAP_EXECUTE |
            SECTION_EXTEND_SIZE);
        public const UInt32 FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS;
        #endregion
        [DllImport("kernel32", SetLastError = true)]
        [System.Security.SuppressUnmanagedCodeSecurity()]
        public static extern unsafe bool WriteFile
        (
            SafeFileHandle hFile,      // handle to file
            void* pBuffer,            // data buffer
            int NumberOfBytesToWrite,  // number of bytes to write
            int* pNumberOfBytesWrite,  // number of bytes write
            NativeOverlapped* Overlapped            // overlapped buffer
        );

        [DllImport("kernel32", SetLastError = true)]
        [System.Security.SuppressUnmanagedCodeSecurity()]
        public static extern unsafe bool ReadFile
        (
            SafeFileHandle hFile,      // handle to file
            void* pBuffer,            // data buffer
            int NumberOfBytesToRead,  // number of bytes to read
            int* pNumberOfBytesRead,  // number of bytes read
            NativeOverlapped* Overlapped            // overlapped buffer
        );

        /// <summary>
        /// Set Culture of current assembly.
        /// </summary>
        /// <param name="Culture"></param>
        public static void SetCulture(System.Globalization.CultureInfo Culture)
        {
            IReaper.Properties.StringResources.Culture = Culture;
        }
        /// <summary>
        /// srcdesdesbuflength
        /// </summary>
        /// <param name="des"></param>
        /// <param name="src"></param>
        /// <param name="buflength"></param>
        public static unsafe void StringCopy(char* des, int buflength, string src)
        {
            if (buflength < 0)
                return;
            int i = 0;
            if (src == null)
                src = "";
            for (; i < src.Length && i < buflength - 1; i++)
            {
                des[i] = src[i];
            }
            des[i] = '\0';
        }

    }

    [Flags]
    public enum PageProtection : uint
    {
        NoAccess = 0x01,
        Readonly = 0x02,
        ReadWrite = 0x04,
        WriteCopy = 0x08,
        Execute = 0x10,
        ExecuteRead = 0x20,
        ExecuteReadWrite = 0x40,
        ExecuteWriteCopy = 0x80,
        Guard = 0x100,
        NoCache = 0x200,
        WriteCombine = 0x400,
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.