473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ILockbytes ReadAt Function

Hello
I have this Problem.
I implements the Interface ILockbytes (IStorage).
Take a look:

Public Function GetData(ByVal inILockBytes As ILockBytes)
Try
Dim statss As System.Runtime.InteropServices.STATSTG
inILockBytes.Stat(statss, 0)

!!This Works fine!!
Debug.WriteLine(statss.pwcsName)

!!This Works too!!
Debug.WriteLine(statss.cbSize.ToString)

!!This Works too!!
Debug.WriteLine(statss.type.ToString)

Dim sizee As Int32 = statss.cbSize

Dim nybytes As Byte() = New Byte(sizee) {}

Dim newptr As IntPtr = Marshal.AllocCoTaskMem(sizee)

!!This fails!!
reads = inILockBytes.ReadAt(0, newptr, sizee)

Marshal.Copy(newptr, nybytes, 0, sizee)

Marshal.FreeCoTaskMem(newptr)
....................

Have anywhere an Solution or an Sample or something else?

Christian
Nov 20 '05 #1
3 1713
Christian,
!!This fails!!
reads = inILockBytes.ReadAt(0, newptr, sizee)


How does it fail? Do you get an exception, and if so what HRESULT does
it have? If you don't get an exception, what's the value of reads
after the call?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #2
Sorry no response.

It crash only. I think there is no response because it is
inILockBytes.ReadAt is unmanage code.

Sometime I get this Message:

System.NullReferenceException: The Objectref is not linked to
Objectinstance.

at System.Runtime.InteropServices.Marshal.CopyBytesTo Managed(Int32 source,
Byte[] destination, Int32 startIndex, Int32 length)

at System.Runtime.InteropServices.Marshal.Copy(IntPtr source, Byte[]
destination, Int32 startIndex, Int32 length)

Thanks

Christian

"Mattias Sjögren" <ma********************@mvps.org> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
Christian,
!!This fails!!
reads = inILockBytes.ReadAt(0, newptr, sizee)


How does it fail? Do you get an exception, and if so what HRESULT does
it have? If you don't get an exception, what's the value of reads
after the call?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 20 '05 #3
Christian,

Did you declare the ILockBytes interface yourself? If so, can you post
the declaration?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
6
by: pablo | last post by:
Dear Newsgroupers, The 'main' page contains a call to a function in an included file. This function puts a html-form on the screen. Before the form gets posted (to the 'main' page) some prior...
9
by: Lenard Lindstrom | last post by:
I was wondering if anyone has suggested having Python determine a method's kind from its first parameter. 'self' is a de facto reserved word; 'cls' is a good indicator of a class method ( __new__...
10
by: Brad Tilley | last post by:
Is there an easier way to do this: def print_whats_returned(function): print function print type(function)
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
1
by: Ken Fine | last post by:
I have a menu system that has nodes that can be opened or closed. In an effort to make my code more manageable, I programmed a little widget tonight that keeps track of the open/active item and...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
17
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.