当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.ToInt32方法代码示例

本文整理汇总了C#中IntPtr.ToInt32方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.ToInt32方法的具体用法?C# IntPtr.ToInt32怎么用?C# IntPtr.ToInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IntPtr的用法示例。


在下文中一共展示了IntPtr.ToInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HiWord

 public static int HiWord(IntPtr dWord)
 {
     if ((dWord.ToInt32() & 0x80000000) == 0x80000000)
         return (dWord.ToInt32() >> 16);
     else
         return (dWord.ToInt32() >> 16) & 0xffff;
 }
开发者ID:svn2github,项目名称:eztx,代码行数:7,代码来源:NativeMethods.cs

示例2: Start

    ///   <summary>
    ///   开始显示图像
    ///   </summary>
    public void Start()
    {
        if (bWorkStart)
            return;
        bWorkStart = true;
        byte[] lpszName = new byte[100];
        hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD | WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr, 0);
        if (hWndC.ToInt32() != 0)
        {
            try
            {
                SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
                SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
                SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
                SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
                SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
                SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
                SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
                SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
            }
            catch (Exception ex)
            {

                throw;
            }

            //Global.log.Write( "SendMessage ");
        }
        return;
    }
开发者ID:huzuohuyou,项目名称:VideoSurveillance,代码行数:33,代码来源:VideoWork.cs

示例3: GetLetterBoundingBoxes

    /// <summary>
    /// Returns the axis-aligned bounding boxes for all letters of the word. These are defined in the range of [0, 1] which corresponds to the whole bounding box of the word.
    /// </summary>
    public RectangleData[] GetLetterBoundingBoxes()
    {
        if (!QCARRuntimeUtilities.IsQCAREnabled())
            return new RectangleData[0];

        if (mLetterBoundingBoxes == null)
        {
            var length = mText.Length;
            mLetterBoundingBoxes = new RectangleData[length];

            var rectPtr = Marshal.AllocHGlobal(length * Marshal.SizeOf(
                                    typeof(RectangleData)));
            QCARWrapper.Instance.WordGetLetterBoundingBoxes(ID, rectPtr);

            var c = new IntPtr(rectPtr.ToInt32());
            for (var i = 0; i < length; i++)
            {
                mLetterBoundingBoxes[i] = (RectangleData)Marshal.PtrToStructure(c, typeof(RectangleData));
                c = new IntPtr(c.ToInt32() + Marshal.SizeOf(
                    typeof(RectangleData)));
            }
            Marshal.FreeHGlobal(rectPtr);
        }
        return mLetterBoundingBoxes;
    }
开发者ID:carrizofm2010,项目名称:app012-acuariotribuno,代码行数:28,代码来源:WordImpl.cs

示例4: bgThread2WndProc

 public bgThread2WndProc(bgThread2 Parent)
 {
     System.Diagnostics.Debug.WriteLine("Creating ThreadWnd...");
     this._bgThread2 = Parent;
     hwndControl = Hwnd;
     System.Diagnostics.Debug.WriteLine("bgThread2WndProc hWnd is 0x: "+hwndControl.ToInt32().ToString("x"));
 }
开发者ID:andrejpanic,项目名称:win-mobile-code,代码行数:7,代码来源:bgThread2.cs

示例5: PosTest1

    /// <summary>
    /// for testing 
    /// </summary>
    /// <returns></returns>
    public bool PosTest1(string id, int i)
    {
        bool retVal = true;
        try
        {
            System.IntPtr ip = new IntPtr(i);
            if (ip.ToInt32() != i)
            {
                TestLibrary.TestFramework.LogError(id,
                    String.Format("IntPtr value expect {0}", i));
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError(id, "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:25,代码来源:intptrctor_int32.cs

示例6: ptr2string

 // 将字符串指针转换为字符串:读取时只读取指定长度的数据
 public static string ptr2string(IntPtr ptr, int dataLen)
 {
     if (ptr.ToInt32() == 0) return "";
     byte[] data = new byte[dataLen];
     Marshal.Copy(ptr, data, 0, dataLen);
     string rtn = Encoding.UTF8.GetString(data);
     return rtn;
 }
开发者ID:sdgdsffdsfff,项目名称:jwebtop,代码行数:9,代码来源:FastIPCNative.cs

示例7: readPtr

 // 将字符串指针对应数据写入到数据流中,主要用于分段传输的数据的拼接
 public static void readPtr(Stream bos, IntPtr ptr, int dataLen)
 {
     if (ptr.ToInt32() == 0) return;
     byte[] data = new byte[dataLen];
     Marshal.Copy(ptr, data, 0, dataLen);
     bos.Write(data, 0, dataLen);
 }
开发者ID:sdgdsffdsfff,项目名称:jwebtop,代码行数:8,代码来源:FastIPCNative.cs

示例8: VerifyPointer

    private static void VerifyPointer(IntPtr ptr, long expected)
    {
        Assert.Equal(expected, ptr.ToInt64());

        int expected32 = (int)expected;
        if (expected32 != expected)
        {
            Assert.Throws<OverflowException>(() => ptr.ToInt32());
            return;
        }

        int i = ptr.ToInt32();
        Assert.Equal(expected32, ptr.ToInt32());

        Assert.Equal(expected.ToString(), ptr.ToString());
        Assert.Equal(expected.ToString("x"), ptr.ToString("x"));

        Assert.Equal(ptr, new IntPtr(expected));
        Assert.True(ptr == new IntPtr(expected));
        Assert.False(ptr != new IntPtr(expected));

        Assert.NotEqual(ptr, new IntPtr(expected + 1));
        Assert.False(ptr == new IntPtr(expected + 1));
        Assert.True(ptr != new IntPtr(expected + 1));
    }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:25,代码来源:IntPtr.cs

示例9: UpdateVirtualButtons

    // Update Virtual Button states.
    public void UpdateVirtualButtons(int numVirtualButtons, IntPtr virtualButtonPtr)
    {
        Dictionary<int, QCARManagerImpl.VirtualButtonData> vbResults = new Dictionary<int, QCARManagerImpl.VirtualButtonData>();

        // create a dictionary of all results
        for (int i = 0; i < numVirtualButtons; i++)
        {
            IntPtr vbPtr = new IntPtr(virtualButtonPtr.ToInt32() + i*
                                      Marshal.SizeOf(typeof (QCARManagerImpl.VirtualButtonData)));
            QCARManagerImpl.VirtualButtonData vbData = (QCARManagerImpl.VirtualButtonData)
                                                       Marshal.PtrToStructure(vbPtr, typeof (QCARManagerImpl.VirtualButtonData));

            vbResults.Add(vbData.id, vbData);
        }

        List<VirtualButtonBehaviour> vbBehavioursToUpdate = new List<VirtualButtonBehaviour>();

        // go over all trackable behaviours and find the virtual buttons to update
        foreach (TrackableBehaviour trackableBehaviour in mTrackableBehaviours.Values)
        {
            ImageTargetBehaviour it = trackableBehaviour as ImageTargetBehaviour;

            if (it != null && it.enabled)
            {
                foreach(VirtualButtonBehaviour virtualButtonBehaviour in it.GetVirtualButtonBehaviours())
                {
                    if (virtualButtonBehaviour.enabled)
                    {
                        vbBehavioursToUpdate.Add(virtualButtonBehaviour);
                    }
                }
            }
        }

        // update the virtual buttons:
        foreach (VirtualButtonBehaviour virtualButtonBehaviour in vbBehavioursToUpdate)
        {
            QCARManagerImpl.VirtualButtonData vbData;
            if (vbResults.TryGetValue(virtualButtonBehaviour.VirtualButton.ID, out vbData))
            {
                virtualButtonBehaviour.OnTrackerUpdated(vbData.isPressed > 0);
            }
            else
            {
                virtualButtonBehaviour.OnTrackerUpdated(false);
            }
        }
    }
开发者ID:negimochi,项目名称:vuforia_test,代码行数:49,代码来源:StateManagerImpl.cs

示例10: Vec3

 public Vec3(IntPtr Memory)
 {
     vec = new float[3];
     X = Mem.ReadFloat(Memory);
     Y = Mem.ReadFloat((IntPtr)(Memory.ToInt32() + sizeof(float)));
     Z = Mem.ReadFloat((IntPtr)(Memory.ToInt32() + (sizeof(float) * 2)));
 }
开发者ID:TETYYS,项目名称:VCTRNR,代码行数:7,代码来源:General.cs

示例11: Reader

 private int Reader(int handle, IntPtr buffer, int length, IntPtr user)
 {
     return basbuffer.Read(buffer, length, user.ToInt32());
 }
开发者ID:krikelin,项目名称:MediaChrome,代码行数:4,代码来源:BassPlayer.cs

示例12: Serialize

            public IntPtr Serialize(params object[] objs)
            {
                int valueSize	= Marshal.SizeOf(typeof(Value));
                int IntPtrSize	= Marshal.SizeOf(typeof(IntPtr));
                int IntSize		= Marshal.SizeOf(typeof(int));
                int numElem		= objs.Length;
                IntPtr ptr		= IntPtr.Zero;

                if (numElem > 0)
                {
                ptr = Marshal.AllocCoTaskMem(valueSize * numElem);
                for (int i = 0; i < numElem; i++)
                {
                Value val;

                object currentObj = objs[i];
                if (!(currentObj is Value))
                {
                    val = CreateValue(currentObj);
                }
                else
                {
                    val = (Value)currentObj;
                }

                // Can't add an integer offset to IntPtr as you would with C/C++ pointer
                IntPtr data = new IntPtr(ptr.ToInt32() + valueSize * i);
                Marshal.WriteIntPtr(data, val.pInternalData);
                data = new IntPtr(data.ToInt32() + IntPtrSize);
                Marshal.WriteInt32(data, (int)val.Type);
                data = new IntPtr(data.ToInt32() + IntSize);
                Marshal.WriteInt64(data, (long)val.MovieId);
                }
                }
                return ptr;
            }
开发者ID:BiDuc,项目名称:Stereoscopic_Scatterplot,代码行数:36,代码来源:SFValue.cs

示例13: WinEventProc

    private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint
                    dwEventThread, uint dwmsEventTime)
    {
        if ((idObject == 0) && (idChild == 0))
        {
            if (psi.isSpotifyAvailable() && hwnd.ToInt32() == psi.getSpotifyWindowHandle().ToInt32())
            {
                string track = tmd.getTrack();
                string artist = tmd.getArtist();

                if (track != null || artist != null)
                {
                    //Console.WriteLine(artist + " - " + track);
                    notify.showViaToast(myForm, track, artist);
                    //Console.WriteLine("Finished Showing");
                }
            }
        }
    }
开发者ID:buildist,项目名称:SpotifyToaster,代码行数:19,代码来源:MainSpotify.cs

示例14: processTouches

    void processTouches(IntPtr wParam, IntPtr lParam)
    {
		int inputCount = LOWORD(wParam.ToInt32());
        TOUCHINPUT[] inputs = new TOUCHINPUT[inputCount];

        if (!GetTouchInputInfo(lParam, inputCount, inputs, touchInputSize))
        {
            return;		
        }

        for (int i = 0; i < inputCount; i++)
        {
            TOUCHINPUT touch = inputs[i];
			updateTouchFromWM(touch);
        }

        CloseTouchInputHandle(lParam);
    }
开发者ID:badbod99,项目名称:unity3d-tuio,代码行数:18,代码来源:WM_Tracking.cs

示例15: RunTest

    public static int RunTest(IntPtr affinity, string processName, string processArgs, int seed)
    {

        // run the test
        Random rand = null;

        Process p = Process.Start(processName, processArgs);
        
        // cannot set the affinity before the process starts in managed code
        // This code executes so quickly that the GC heaps have not yet been initialized,
        // so it works.
        if (affinity != IntPtr.Zero)
        {
            // set affinity to (2^n)-1, where n=affinity
            int newAffinity = (int)Math.Pow(2, affinity.ToInt32())-1;
            p.ProcessorAffinity = new IntPtr(newAffinity);
            Console.WriteLine("Affinitizing to {0}", newAffinity); 
        }
        else
        {
            rand = new Random(seed);
            Console.WriteLine("Using random seed: {0}", seed);
        }

        while (!p.HasExited)
        {
            // change affinity randomly every 5 seconds
            Thread.Sleep(5000);
            if (affinity == IntPtr.Zero)
            {
                try
                {
                    // randomly change the affinity between 1 and (2^n)-1, where n=numProcessors
                    int newAffinity = rand.Next(1, (int)Math.Pow(2, Environment.ProcessorCount)-1);
                    p.ProcessorAffinity = new IntPtr(newAffinity);
                    Console.WriteLine("Affinitizing to {0}", newAffinity);
                }
                // we couldn't set the affinity, so just exit
                catch (InvalidOperationException)
                {
                    break;
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    break;
                }
            }

        }

        Console.WriteLine("Exiting with exit code {0}", p.ExitCode);
        return p.ExitCode;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:53,代码来源:affinitizer.cs


注:本文中的IntPtr.ToInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。