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


C# IntPtr.ToInt64方法代码示例

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


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

示例1: Add

    public void Add(Vector3 in_Pos, Vector3 in_Forward, Vector3 in_Top, uint in_ChannelMask)
    {
        if (m_Count >= m_MaxCount)
            throw new IndexOutOfRangeException("Out of range access in AkChannelEmitterArray");

        //Marshal doesn't do floats.  So copy the bytes themselves.  Grrr.
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.x), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.y), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.z), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Top.x), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Top.y), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Top.z), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.x), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.y), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.z), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, (int)in_ChannelMask);
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(uint));

        m_Count++;
    }
开发者ID:TheWanderingTree,项目名称:temple,代码行数:29,代码来源:AkChannelEmitterArray.cs

示例2: MarshalNativeToManaged

 public object MarshalNativeToManaged(IntPtr pNativeData)
 {
     //Console.WriteLine ("ToManaged: " + pNativeData);
     native_to_managed_count ++;
     native_to_managed_result = param + Marshal.ReadInt32 (new IntPtr (pNativeData.ToInt64 () + 4));
     return native_to_managed_result;
 }
开发者ID:robertmichaelwalsh,项目名称:Multilex,代码行数:7,代码来源:marshal9.cs

示例3: CleanUpNativeData

    public void CleanUpNativeData(IntPtr pNativeData)
    {
        Console.WriteLine("CleanUpNativeData called");
        if (pNativeData != IntPtr.Zero) {
            IntPtr realPtr = new IntPtr (pNativeData.ToInt64 () - Marshal.SizeOf (typeof (int)));

            Marshal.FreeHGlobal (realPtr);
        }
    }
开发者ID:robertmichaelwalsh,项目名称:CSharpFrontEnd,代码行数:9,代码来源:marshal9.cs

示例4: CleanUpNativeData

 public override void CleanUpNativeData(IntPtr native_data)
 {
     Marshal.FreeHGlobal(native_data);
     #if MARSHAL_DEBUG
     // Useful for debugging things from a console application to see whether
     // allocating and freeing match.  We cannot use Log.Info here, since that
     // would recursively call the marshaler and end in overflowing hilarity.
     Console.WriteLine("freeh " + Convert.ToString(native_data.ToInt64(), 16));
     #endif
 }
开发者ID:pleroy,项目名称:Principia,代码行数:10,代码来源:utf8_marshaler.cs

示例5: Add

    public void Add(uint in_EnvID, float in_fValue)
    {
        if (m_Count >= m_MaxCount)
            Resize(m_Count * 2);

        Marshal.WriteInt32(m_Current, (int)in_EnvID);
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(uint));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_fValue), 0));  //Marshal doesn't do floats.  So copy the bytes themselves.  Grrr.
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        m_Count++;
    }
开发者ID:TheWanderingTree,项目名称:temple,代码行数:11,代码来源:AkAuxSendArray.cs

示例6: LoadFile

    IEnumerator LoadFile()
    {
        ms_www = new WWW(m_bankPath);

        yield return ms_www;

        uint in_uInMemoryBankSize = 0;

        // Allocate an aligned buffer
        try
        {
            ms_pinnedArray = GCHandle.Alloc(ms_www.bytes, GCHandleType.Pinned);
            ms_pInMemoryBankPtr = ms_pinnedArray.AddrOfPinnedObject();
            in_uInMemoryBankSize = (uint)ms_www.bytes.Length;

            // Array inside the WWW object is not aligned. Allocate a new array for which we can guarantee the alignment.
            if( (ms_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0 )
            {
                byte[] alignedBytes = new byte[ms_www.bytes.Length + AK_BANK_PLATFORM_DATA_ALIGNMENT];
                GCHandle new_pinnedArray = GCHandle.Alloc(alignedBytes, GCHandleType.Pinned);
                IntPtr new_pInMemoryBankPtr = new_pinnedArray.AddrOfPinnedObject();
                int alignedOffset = 0;

                // New array is not aligned, so we will need to use an offset inside it to align our data.
                if( (new_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0 )
                {
                    Int64 alignedPtr = (new_pInMemoryBankPtr.ToInt64() + AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) & ~AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK;
                    alignedOffset = (int)(alignedPtr - new_pInMemoryBankPtr.ToInt64());
                    new_pInMemoryBankPtr = new IntPtr(alignedPtr);
                }

                // Copy the bank's bytes in our new array, at the correct aligned offset.
                Array.Copy (ms_www.bytes, 0, alignedBytes, alignedOffset, ms_www.bytes.Length);

                ms_pInMemoryBankPtr = new_pInMemoryBankPtr;
                ms_pinnedArray.Free();
                ms_pinnedArray = new_pinnedArray;
            }
        }
        catch
        {
            yield break;
        }

        AKRESULT result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID);
        if( result != AKRESULT.AK_Success )
        {
            Debug.LogError ("AkMemBankLoader: bank loading failed with result " + result.ToString ());
        }
    }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:50,代码来源:AkMemBankLoader.cs

示例7: OnHookedWindowMessage

        static IntPtr OnHookedWindowMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == Win32Interop.WM_SYSCOMMAND && wParam.ToInt64() == (long)Win32Interop.SC_CONTEXTHELP)
            {
                var rootVisual = HwndSource.FromHwnd(hwnd).RootVisual;
                var focusedElement = FocusManager.GetFocusedElement(rootVisual);
                if (focusedElement == null)
                {
                    focusedElement = rootVisual as IInputElement;
                }
                ApplicationCommands.Help.Execute(null, focusedElement);
                handled = true;
            }

            // According to MSDN, zero should be returned after handling WM_SYSCOMMAND.
            // If this message is unhandled, it's still safe to return zero
            // because WPF framework (HwndSource) will return zero anyway if the
            // message is unhandled.
            return IntPtr.Zero;
        }       
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:20,代码来源:DialogWindow.cs

示例8: Add

    public void Add(Vector3 in_Pos, Vector3 in_Forward)
    {
        if (m_Count >= m_MaxCount)
            throw new IndexOutOfRangeException("Out of range access in AkPositionArray");

        //Marshal doesn't do floats.  So copy the bytes themselves.  Grrr.
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.X), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.Y), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Pos.Z), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.X), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.Y), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));
        Marshal.WriteInt32(m_Current, BitConverter.ToInt32(BitConverter.GetBytes(in_Forward.Z), 0));
        m_Current = (IntPtr)(m_Current.ToInt64() + sizeof(float));

        m_Count++;
    }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:21,代码来源:AkPositionArray.cs

示例9: PosTest1

    /// <summary>
    /// for positive testing 
    /// </summary>
    /// <returns></returns>
    public bool PosTest1(string id, long i)
    {
        bool retVal = true;
        try
        {
            System.IntPtr ip = new IntPtr(i);
            if (ip.ToInt64() != 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_int64.cs

示例10: OnReadUnix

 void OnReadUnix(UVBuffer.Unix buffer, IntPtr bytesAvaliable)
 {
     long bytesRead = bytesAvaliable.ToInt64();
     if (bytesRead == 0)
     {
         return;
     }
     else if (bytesRead < 0)
     {
         var error = UVException.ErrorCodeToError((int)bytesRead);
         if (error == UVError.EOF)
         {
             OnEndOfStream();
             Dispose();
         }
         else
         {
             Dispose();
             throw new UVException((int)bytesRead);
         }
     }
     else
     {
         var readSlice = new ByteSpan((byte*)buffer.Buffer, (int)bytesRead);
         OnReadCompleted(readSlice);
         buffer.Dispose();
     }
 }
开发者ID:Anniepoh,项目名称:corefxlab,代码行数:28,代码来源:Stream.cs

示例11: OnReadWindows

 void OnReadWindows(UVBuffer.Windows buffer, IntPtr bytesAvaliable)
 {
     // TODO: all branches need to release buffer, I think
     long bytesRead = bytesAvaliable.ToInt64();
     if (bytesRead == 0)
     {
         buffer.Dispose();
         return;
     }
     else if (bytesRead < 0)
     {
         var error = UVException.ErrorCodeToError((int)bytesRead);
         if (error == UVError.EOF)
         {
             OnEndOfStream();
             Dispose();
             buffer.Dispose();
         }
         else if(error == UVError.ECONNRESET)
         {
             Debug.Assert(buffer.Buffer == IntPtr.Zero && buffer.Length == 0);
             // no need to dispose
             // TODO: what should we do here?
         }
         else
         {
             Dispose();
             buffer.Dispose();
             throw new UVException((int)bytesRead);
         }
     }
     else
     {
         var readSlice = new ByteSpan((byte*)buffer.Buffer, (int)bytesRead);
         OnReadCompleted(readSlice);
         buffer.Dispose();
     }
 }
开发者ID:Anniepoh,项目名称:corefxlab,代码行数:38,代码来源:Stream.cs

示例12: StreamGetHeaderImpl

			public int StreamGetHeaderImpl (IntPtr buf, int bufsz)  {
				int	bytesRead;

				start_buf = new byte[bufsz];

				try {
					bytesRead = stream.Read (start_buf, 0, bufsz);
				} catch (IOException) {
					return -1;
				}

				if (bytesRead > 0 && buf != IntPtr.Zero) {
					Marshal.Copy (start_buf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
				}

				start_buf_pos = 0;
				start_buf_len = bytesRead;

				return bytesRead;
			}
开发者ID:Profit0004,项目名称:mono,代码行数:20,代码来源:gdipFunctions.cs

示例13: StreamGetBytesImpl

			public int StreamGetBytesImpl (IntPtr buf, int bufsz, bool peek) 
			{
				if (buf == IntPtr.Zero && peek) {
					return -1;
				}

				if (bufsz > managedBuf.Length)
					managedBuf = new byte[bufsz];
				int bytesRead = 0;
				long streamPosition = 0;

				if (bufsz > 0) {
					if (stream.CanSeek) {
						streamPosition = stream.Position;
					}
					if (start_buf_len > 0) {
						if (start_buf_len > bufsz) {
							Array.Copy(start_buf, start_buf_pos, managedBuf, 0, bufsz);
							start_buf_pos += bufsz;
							start_buf_len -= bufsz;
							bytesRead = bufsz;
							bufsz = 0;
						} else {
							// this is easy
							Array.Copy(start_buf, start_buf_pos, managedBuf, 0, start_buf_len);
							bufsz -= start_buf_len;
							bytesRead = start_buf_len;
							start_buf_len = 0;
						}
					}

					if (bufsz > 0) {
						try {
							bytesRead += stream.Read (managedBuf, bytesRead, bufsz);
						} catch (IOException) {
							return -1;
						}
					}
			
					if (bytesRead > 0 && buf != IntPtr.Zero) {
						Marshal.Copy (managedBuf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
					}

					if (!stream.CanSeek && (bufsz == 10) && peek) {
						// Special 'hack' to support peeking of the type for gdi+ on non-seekable streams
					}
				
					if (peek) {
						if (stream.CanSeek) {
							// If we are peeking bytes, then go back to original position before peeking
							stream.Seek (streamPosition, SeekOrigin.Begin);
						} else {
							throw new NotSupportedException();
						}
					}
				}
				
				return bytesRead;
			}
开发者ID:Profit0004,项目名称:mono,代码行数:59,代码来源:gdipFunctions.cs

示例14: AssertByrefPointsToStack

 private static void AssertByrefPointsToStack(IntPtr ptr) {
     if (Marshal.ReadInt32(ptr) == _dummyMarker) {
         // Prevent recursion
         return;
     }
     int dummy = _dummyMarker;
     IntPtr ptrToLocal = ConvertInt32ByrefToPtr(ref dummy);
     Debug.Assert(ptrToLocal.ToInt64() < ptr.ToInt64());
     Debug.Assert((ptr.ToInt64() - ptrToLocal.ToInt64()) < (16 * 1024));
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:10,代码来源:ComRuntimeHelpers.cs

示例15: HotKeyEventArgs

 public HotKeyEventArgs(IntPtr hotKeyParam)
 {
     uint param = (uint)hotKeyParam.ToInt64();
     Key = (Keys)((param & 0xffff0000) >> 16);
     Modifiers = (KeyModifiers)(param & 0x0000ffff);
 }
开发者ID:gabrielnahmias,项目名称:Globule,代码行数:6,代码来源:HotKeyManager.cs


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