realbasic-nug
[Top] [All Lists]

Turning a MemoryBlock of Bytes back into an integer.

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Turning a MemoryBlock of Bytes back into an integer.
From: Christian Miller <rblists@pariahware.com>
Date: Thu, 15 Jul 2010 22:04:39 -0400
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com; dkim=neutral (body hash did not verify) header.i=@pariahware.com
Delivered-to: listarchive@realsoftware.com
Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=pariahware.com; h=from :content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; s=pariahware.com; bh=xFVwblxtJJL0Z+Uml4Vq75oWX kg=; b=nlnlR0Vj3a+wHrqpBjrFoGzqYFtMf/3qxfq/faQ2+xE+eHbgobIac//JJ xygKNmkue15bHr/4d4x2vFZFhE6KEEH7wRRndo+eyBJqpesDPvK8UBFTFghNxi+O O231cWpaceuWdUgZRDQIPveeU1dvtKLGogp5raEPwPb+rkrkuc=
Domainkey-signature: a=rsa-sha1; c=nofws; d=pariahware.com; h=from :content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; q=dns; s=pariahware.com; b=rDBSTivaiIyWJqQSb+r m4jzKQzXzEa3PytcHwwGG4WvneFeS1YJZyfpAo3V0vA5bQQhcURChyT82Z6U72yE 8F2skqBTPubyNXmEYan9xS6iF50GdiAjCvODYlUDGyPYHIj1C6x2NQjg6aok+LOi 6b8VhgcgeZfTu4tSbxWJE0UQ=
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
I'm receiving a DWORD (integer) from a Windows API call.  I toss the integer 
into a 4 byte MemoryBlock.  Some how I need to convert the bytes back into an 
integer.  The routine is as follows:

I'm pretty sure I need to do some bitwise math on the bytes pulled out, but I'm 
just not getting it right.  Please help. Thanks. :)

Private Function IntegerToPort(int as UInt32) As String
  dim myNewMagicBlock as new MemoryBlock(4)
  myNewMagicBlock.UInt32Value(0) = int
  
  dim a, b, c, d as byte
  dim e as UInt64
  dim f as string
  
  a = myNewMagicBlock.Byte(0)
  b = myNewMagicBlock.Byte(1)
  c = myNewMagicBlock.Byte(2)
  d = myNewMagicBlock.Byte(3)
  'e = ?
  f = Str(e)

  Return f
  
End Function


Christian
Pariahware, Inc.
Mac, Windows, Linux, & iPhone Consulting
<pariahware@pariahware.com>
<http://www.pariahware.com>
--
God loved you so much that He gave His only son Jesus.  What have you done with 
God's gift?






_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>