How To Return SafeArray From C++ (ATL)

Apr 20, 2012

I created a ATL project and I got a function like

idl File:
[id(1)] HRESULT COM_TEST( [in] int parm_count, [in, out] SAFEARRAY(PARM) *parm, [out, retval] short *return_code )
cpp file:
STDMETHODIMP CTEST::COM_TEST( int parm_count, SAFEARRAY **parm, short *return_code

[Code].....

My question is how do I input a array and output it?

View 1 Replies


ADVERTISEMENT

Initializing A SAFEARRAY Ref In C# (port From VB?)?

Nov 21, 2011

I am working with a third-party COM component (i.e. do not have its code). The method in question has the following outline:

HRESULT GetTableInfo(
[in] BSTR bstrTableName,
[in,out] SAFEARRAY(BSTR) bstrColumnTitles,
[in,out] SAFEARRAY(long) lColumnPos );

I have tried to pass a ref to a fixed-size array ((Array)string[6]) and to a List.ToArray(), but it keeps crashing on me. E.g.

Array arr1 = (Array) new string[500];
Array arr2 = (Array) new int[500];
table.GetTableInfo(filename, ref arr1, ref arr2);

To be more specific: I already tried any value for the size (the correct one should be 44). Tried the same for the capacity of a List<>, but that didn't help either. I also tried different types, but it does not accept any other than int.

I don't know why it keeps crashing on me with a general error of that COM component (basically indicating that something is wrong, yet not saying what exactly), since I can confirm that the following VB code works:

Dim TitleList() As String
Dim PositionList() As Long
Call objTable.GetTableInfo(txTableFile.Text, TitleList, PositionList)

View 1 Replies

Can Still Get Safearray And Bitmap STRUCTURES (not Classes) In .NET 2005

Sep 27, 2009

I have tried this question several times, sometimes a little in the face of MS VB teams but with no constructive answers. Perhaps with too much rant. I suspect that VB.NET does not allow me to do what I can easly do in VB5.0. The VB team should easily be able to supply the information I need, but have not yet answered the questions. I want to do a lot of work on very large bitmaps (20 Mp or more; 80Mb or more ARGB) using arrays for access. This I used to do in VB5.0 using the SAFEARRAY and BITMAP STRUCTURES. NOT the corresponding .NET CLASSES. But I now need to use an SDK requiring .NET. However, through lack of wisdom, the VB team dropped 5 critical resources on the move to VB.NET - VarPtr, VarPtrArray, the 2 structures and CopyMemory. The SAFEARRAY CLASS seems to lack a set method for array data and the BITMAP CLASS seems to lack both get and set methods for data. On building a .NET solution using VB.NET, c#.NET and C++.NET projects I could not locate the set and get methods. Interop could not upgrade my VB5.0 to VB2005 - presumably on account of these 5 problems. I was surprised that even C++ suffered too. .NET hurts. So, first off, two critcal simple questions: A) Bearing in mind that much of the .NET is tinsel-wrapped APIs, does a pointer to an array still point to a defining SAFEARRAY STRUCTURE of the original format (NOT of course to a first element of an array). If that is so, I am lucky for I can then fill and use (perhaps) my own SAFEARRAY STRUCTURE by memory manipulation in C++. B) If the same applies to a bitmap pointer I can then perhaps do the same with BITMAP STRUCTURES. If that can be done I can hopefully work in a .NET solution containing C++ (for the pointer and mmory work) and VB2005 (for the rest of the work). I can then 1) in VB define two empty byte-arrays GLOBAL in VB.NET- Pic1() and Pic2(). They do not need to be dimensioned. SAFE FROM GC 2) in VB define two GLOBAL SAFEARRAYS to match the arrays, one with one and another with 2 dims matching the bitmap in size. SAFE FROM GC 3) move ByRef the 4 objects to VC++. STILL SAFE FROM GC, LEFT EXACTLY WHERE THEY WERE. 3) copy the BITMAP data pointers to the data pointers of the SAFEARRAYS. DOES NOT MOVE ANYTHING. 4) copy the addresses of the SAFEARRAYS to the corresponding arrays STILL DOES NOT MOVE ANYTHING, BUT JOB DONE. And then I will be able to process the images in seconds rather than minutes after moving only 4 4-byte numbers. I would welcome alternative sequences, provided they DO NOT involve put and set pixels or array elements on the trivial side and do not involve moving 80Mb of image data between "safe" and "unsafe" memory on the Herculian side. Else, as the Pic() ans Safearrays MUST point somehow to structures, WHAT EXACTLY ARE THEY, AND WHERE? I want to access them. If I can't overcome these 5 silly MS blunders I'll just have to build two uncoupled projects - one in VB5.0 and the other in VB/VC++ .NET. I'm not going to get involved myself with tinsel and gladwrap workarounds.

View 4 Replies

[VB 2010] Return Alert Message If SQL Query Return No Records

Dec 12, 2011

I use this code to return records in a DataGridView:

[Code]....

View 3 Replies

Return An Object As The Return Value Through A RealProxy Transparent Proxy?

Oct 7, 2010

I'm working up a system where I plan on using RealProxy objects to enable intercepting method calls against a set of objects, handling the call, and then returning appropriate results. This works just find for simple return types like strings or ints, but I can't seem to return objects from the RealProxy.Invoke method. Everything works. I get no errors, but the returned value is always NOTHING, instead of an object.

I've worked up the smallest sample code I could, and have included it below. Essentially, just call RPtest and single step through. The code creates a simple object, RPTestA, with a string field and an object valued field It then retrieves the string

[Code]...

View 1 Replies

Checking If A Port Is Open - If It Is Open Then Return True, If It's Closed, Return False?

Dec 28, 2010

I'm making a Visual Basic GUI application to display whether a number of my ports are open for people to know whether things like my website and my Minecraft server are open.My problem is I have absolutely no idea how to do this in Visual Basic.Basically, I'm asking for something which sends a signal to an IP with a specific port, if it is open then return true, if it's closed, return false. Similar to: http:[url]....

View 1 Replies

Using LINQ To Return Element In Collection, Would Like To Return Nothing If Element Not Found?

Mar 3, 2011

I would like the following function to return Nothing if the element with the specified key is not in the collection. Instead, it returns an error - something to the effect of "no element found"

Public Class MyCollection
Inherits System.Collections.ObjectModel.Collection(Of MyType)
Public Function FindByActivityKey(ByVal searchValue As Integer) As MyType

[code]....

View 1 Replies

Function Return - Assign A Value To The "Functions Name" Or Use "return Value"

Jan 16, 2009

In order to return a value from a VB.NET function one can assign a value to the "Functions Name" or use "return value." I sometimes see these inter-mixed in the same function. Personally, I prefer the return. My question is, what is the internal difference, if any, between the two?

View 5 Replies

Get Return Value Of Exe?

Feb 17, 2009

I am working in Microsoft Visual Studio 2003.

I want to execute file using command line argument.

Actually my requirement is run the vb.net exe file in PHP. In Php exe is running using the exec command.

In my exe file i copy a file from one folder to another folder. I have to return whether that file is copied successfully or not to php.

how can i send this information to php from vb.net.

My code is

Dim sourcepath, source, filename As String
Dim destinationpath As String
Dim processvalue As Integer

[Code]....

View 1 Replies

How To Return A Value

Aug 13, 2011

[Code]...

Dim mappath As MatchCollection = r.Matches(randomstring) when changed to derp doesn't work. Derp does work when you put it in a message box too. I tried .tostring. I don't know what to do D:) I tried tostring, I tried converting with cstr but it say's it cannot return a value, what do?

View 1 Replies

The Return Value Is 0?

Aug 2, 2011

view the code below

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code]....

Why when click the button1, the return is 0 but not -1?

View 4 Replies

What Does 'Return Not (s Is Nothing)' Return

Feb 8, 2010

Can someone explain me the behaviour of the following line in VB Return Not (s Is Nothing)I am looking to translate this in C# and i am not sure about those negation and do not understand the conditions.

View 3 Replies

What Should A DAL Return To BLL

Mar 5, 2010

I am new to n-tier applications.should the DAL return a class or dataset to the BLL?

View 2 Replies

.net - Return Object() From WCF

Aug 17, 2011

I have a WCF service wich has this function:

[Code]...

wich returns the values specified here:

[Code]...

Each one of this functions returns a List of entities. If I call this functions individually they return their values ok. But what I want is to make only one call to the service and no several! I want to be able to receive it in another application like this:

[Code]...

View 1 Replies

.NET Function Return Value?

Jun 15, 2011

Possible Duplicate: VB.NET Function Return If I have a function that returns a boolean, what is the difference between:Return False and Function = False

View 2 Replies

Asp.net - Why The 'index' Always Return Value 0

Mar 20, 2012

Why the 'index' always return value 0 although the ticker running and there is a statement 'index = index + 1'?

'Dim index as integer = 0
'EDIT
Dim GridRowIndex as integer

[code]....

View 2 Replies

Cannot Get Return Value From Sql Procedure

Aug 19, 2011

I have tried ADO, now I've moved to SQLClient and I still cannot retrieve the return value from my procedure.

Here is my VB code:

cmd.CommandText = "usp_executeMerge"
cmd.CommandType = CommandType.StoredProcedure
Dim retparm As New SqlClient.SqlParameter

[code]....

My mergeResults table shows the return value of 99 but I cannot get any value back to my VB program.

View 1 Replies

Events Return A Value Like I Can Do In C#?

Oct 14, 2011

In C#, I can do this:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)[code]....

Notice the line int i = c1.GetInt();. I can't seem to get VB.NET 4.0 to do something similiar.

View 3 Replies

Function Does Not Return Nothing?

Feb 12, 2010

take a look at the following Code:

Private Sub btnDebug_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDebug.Click
Dim d As Date

[Code]....

The Funtion ZZNull always returns Nothing, so IsNothing(d) in the calling method should evaluate to True.

But it does not !

When you run these lines, then you will see that IsNothing(d) evaluates to False

View 7 Replies

Get A Function's Return Value?

Jan 14, 2012

In the documentation of FileInfo.Create Method it says:

'Declaration
Public Function Create As FileStream
'Usage

[code].....

View 7 Replies

Get The Return Of A CLI Command?

Sep 21, 2011

I need to read the status of HP RAID Controllers out of the HP CLI.Thats quite simple, but I need to get the return of the CLI back to VB.

Sub Main()
Dim myString As String
Dim my2string As String

[code]....

View 15 Replies

Getting A Char Return Value From A DLL?

Sep 27, 2010

I am currently using a C .dll file in my vb.net project, and need to access a string that it returns (as a pointer to a char array). How can I access this?

Private Declare Function src_error Lib "libsamplerate.dll" (ByVal err As Integer) As (???) 'i've tried intptr, string, integer, none work
<MarshalAs(UnmanagedType.LPTStr)> Dim ptr As String

...and then in the actual function,

ptr = src_error(6) 'returns an error based on what combination of things I've tried

View 2 Replies

How To Add A Return Attribute

Oct 2, 2009

I am converting C# code to VB.Net and the C code has this above the function:[return: System.Xml.Serialization.XmlElementAttribute("Name", IsNullable=true)]

View 3 Replies

How To Return The Variable Name Itself

Dec 10, 2010

1. How to return the variable name itself? Public Class test Public Shared as String = "111" End Class I want to return AAA but no 111, test. = "111", and test. Tostring = "111"

2. I want to join the space char into the variable, for example A B but no AB, how to do?

View 7 Replies

How To Use A Function's Return Value

Mar 8, 2009

So the program I am writing validates the controls on the page on button_click.

I want to write a function which checks which step the program is at (0-7) then return something depending on whether or not it validated.

My plan was to return the control which was not valid.

Private Function ValidateInputs() As Control
Select Case wizardStep
Case 0

[Code].....

1. could I return the names off all the controls which did not validate?

2. should I be returning a control type or would something like a string be better?

View 3 Replies

MeasureCharacterRanges Return Nothing

Jun 25, 2010

Do any one knows what has happened here?

gRef = Panel1.CreateGraphics

Dim r = gRef.MeasureCharacterRanges("123456", SystemFonts.CaptionFont, New RectangleF(PointF.Empty, New SizeF(Single.PositiveInfinity, Single.PositiveInfinity)), StringFormat.GenericDefault)

result -> r.Count = 0

View 1 Replies

Net - Return The Object Associated With The Name

Feb 3, 2012

I'm connecting my program to some external code. I'm setting it up so that the external code can instance objects and I've come across a problem. I've created this function here:

[Code]...

I'm trying to create a System.Diagnostics.Process object. For what ever reason though, it always return Nothing instead of the object. Does anybody know what I'm doing wrong? I'm doing this in VB.net so all .net responses are accepted :)

View 2 Replies

PropertyData.Value No Return?

Feb 28, 2012

Why does props return .name and .type but no .value ? Am I maddd?

Dim MyObj As New ManagementObject
_MyObj.Path.NamespacePath = "root\CIMV2"
_MyObj.Path.ClassName = "Win32_Desktop"

[code].....

View 4 Replies

Return A String From C++ Dll To VB

May 27, 2011

How can I return a string from c++ dll to VB? I want to return a string through return value, not param.So many times, googling but i couldn't find the solution.Here is my sample code, but when the function(testBSTR()) is called,the sample program is crashed.[code]

View 4 Replies

Return A Value From A Thread?

Oct 17, 2009

I tried to make a thread (address of function) , but vb.net didn't accept that.

is there any way to return a value from a thread ?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved