Vb6 - Passing A Structure To Unmanaged Dll?

Feb 22, 2011

I'm migrating some VB6 code to VB.net,the code contains a structure that contains 1d arrays, 2d arrays, and few other variables.The general outline of the Vb.net structure is as under

[code]...

The call to the dll is declared as under Public Declare Sub getState Lib "val.dll" (ByRef state As Test)Elsewhere on this site I realized that we have to "marshal" the structure to allow it to be compatible with the unmanaged code that is about to accept it.However I still receiving runtime errors when running the code, I don't have any clue of how to use the System.Runtime.InteropServices.Marshal class.What would be the correct way to pass this structure to the dll?EDIT: The original VB6 data type is

[code]...

View 1 Replies


ADVERTISEMENT

Passing Parameters To Unmanaged C Api

Mar 3, 2010

I need to call a function in an unmanaged .dll written in C lang from vb.net. The function declaration looks like this [code]Now the behavior of this function is that it copies some data in argument "reply" and returns a numeric value which signals its pass/fail status. How do i pass it a string object so that it can copy data. Following is how i access this function.[code]When the call completes, returned status is absolutely fine but there is nothing in string "str". What is it that i am missing. I'm not sure about the string object that i am passing as argument.

View 3 Replies

Passing Parameters To Unmanaged C Api?

Mar 3, 2010

I need to call a function in an unmanaged .dll written in C lang from vb.net. The function declaration looks like thisLONG _stdcall ReadInfo(char *reply);Now the behavior of this function is that it copies some data in argument "reply" and returns a numeric value which signals its pass/fail status. How do i pass it a string object so that it can copy data.Following is how i access this function.

View 2 Replies

Unmanaged DLL Structure Conversion (unsigned Char Pointer)

Oct 28, 2009

I'm making a "wrapper" for an unmanaged DLL (written, I'm fairly certain in C). I have a c++ "wrapper" that I'm trying to convert to VB.net. I've got most of the program working, but I've hit a brick wall.

I'm trying to convert the following two structures from their c++ versions to their vb.net versions. I cannot be sure which is the problem because both must be passed at the same time. The error I am getting is thrown by the object and indicates "Invalid structure size specified". I can cause this error on other objects when I either don't set the dwSize variable, leave off a parameter or change the parameter type incorrectly. Note that the dwSize parameter is supposed to contain the size of each structure. I'm successfully calculating that for my other structures and I'm using the same method on these and the results appear correct, so I do not believe the problem is found there. The object uses a lot of structures and the rest of them are working. These two are the only ones with a) an unsigned character pointer b) an unsigned long array and c) doubles.

C++ versions:

CODE:

I don't think I'm missing any parameters - the help file seems to agree with me on this, but it's theoretically possible that there is something missing (though I don't think so for other reasons as well). My suspicion is that it's dwPalette, pImageData or pMaskData with (in my uninformed opinion) more suspicion on the pImageData and pMaskData.

View 7 Replies

Passing String Parameter To C++ Unmanaged DLL?

Nov 2, 2011

I'm calling unmanaged C++ Dll function from VB.Net project by usin dllimport attribute like this;

<DllImport("Injection.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Sub Injector(ByRef Client As String, ByRef Dll As String)
End Sub

View 4 Replies

Passing A Pointer To A Structure To A C DLL?

Sep 28, 2010

Private Declare Function src_simple Lib "libsamplerate.dll" (ByVal data As IntPtr, ByVal converter_type As Integer, ByVal channels As Integer) As Integer<br/>
Private Declare Function src_strerror Lib "libsamplerate.dll" (ByVal err As Integer) As IntPtr<br/>
<br/>
<StructLayout(LayoutKind.Sequential, Pack:=1)> _

[code]....

View 1 Replies

Passing Structure To A Form?

Jul 30, 2011

I have a DB with ~25,000 records that I keep in memory, and I need to pass one record to a second form for display.

code snippet follows:

Structure User
Dim First As String
Dim Middle As String
Dim Last As String

[code]....

The second form opens on second screen (Dual monitor) but I'm not sure what I did is correct. I have hit a wall on how to pass the single record from the structure to the form.

View 2 Replies

Passing Structure To Dll File?

Sep 30, 2011

I have the following .dll file created and added as a reference in my calling project; however, being new to vb .net I seem to be having difficulty calling the dll that I created.I want to pass a string to the below function, break that string out into two strings and then return the structure.

Namespace Item_Breakout
Public Class Item_Run_Breakout
Public Structure vbItem_Code[code].....

View 8 Replies

Error In Passing Structure Array To Function

Nov 7, 2011

I'm a beginner when it comes to Visual Basic coding and I need some help with an error I'm getting. I'm trying to pass a structure array to a function to figure out a student's grade. I'm getting the error that 'QuizOne' is not a member of System.Array. Here is my code:

[Code]...

View 3 Replies

Passing Structure As Argument Through Files / Functions

Jun 21, 2012

I can't get to pass structure as argument through subs/functions in different files of single vbnet project like I use to in earlier MS basic versions.[code]File "mysetup.dat" is reachable and data is saved correctly what I can see with HxD.But read part seem's to not work as expected. Please any help on reliable passing structure as argument without too much public elements based on upper example.

View 1 Replies

Print Specific Structure Members When Passing The Name

May 1, 2009

I am trying to figure out how to print specific members of a structure when I only have to pass the structure itself i.e.

Dim Point1 as PointF = New PointF(15,30)
Debug.Print(Point1) ' This will output "{X = 15, Y = 30}" by default

I am trying to figure out how I can do the same with my own strucutres, for example:

Dim Point2 as PointF2D = New PointF2D(15,30)
Debug.Print(Point2) ' This will output "ClassName.PointF2D.Point2"

How can I get my structures, when passed to a print statement, to print specific members of that structure by default? P.S. Please give another way other than overloading the .ToString function.

View 3 Replies

Passing A Structure Containing An Array Of String And An Array Of Integer Into A C++ DLL?

May 27, 2010

I'm having problems with marshaling in VB.NET to C++, here's the code :

In the C++ DLL :
struct APP_PARAM
{

[code].....

View 2 Replies

Passing A Structure From One Class To Another Class In A Applications (VS2008)

Apr 7, 2010

I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.

The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..

[Code]...

View 1 Replies

Structure Inside Another Structure Receives Null Reference Error?

Jan 5, 2012

Module Module1
Public Structure structure1
Public TRANS() As structure2
End Structure
Public Structure structure2
Public X() As Integer
End Structure
End Module

View 17 Replies

Class Structure - Large Structure That Has Lots Of Properties ?

Jan 5, 2010

I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.

Let's say I have a pretty large structure that has lots of properties.

Code:

Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)

Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.

Code:

Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?

In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.

View 11 Replies

Converting Structure Within Structure To Byte Array For Socket

Aug 29, 2009

I am trying to communicate with an external device and i am trying to send a byte array to the external device via sockets but i am always getting a response the message size is too small so i am not sure what i have done wrong. Between the data type there should be no alignment present and all numbers are represented in little endian format. The char array is not null terminated as mentioned in the protocol specifications.

I have to send data based on a struct that embeds 2 other struct. So here's my vb.net code for the struct used to convert to byte array and the sending part.

Public Structure MESSAGETYPE_OIP_Login
Dim Header() As COMMANDHEADER
Dim UserName() As PSTRING

[Code]....

View 2 Replies

Invalid Structure Size When Marshalling C Structure To .NET

Apr 14, 2012

I'm experiencing a problem with the following c-structure:

typedef struct tagTEXTUREPROP
{
DWORD dwSize;

[Code].....

The Marshal.SizeOf obviously calculates a size of 76 and it works with the DLL function, but it leaves me with some bad feelings.

View 1 Replies

VS 2008 Convert The XML Structure Into A Class Structure?

Apr 25, 2010

I'm having a problem that's driving me crazy; I can't understand how to convert the XML structure into a class structure (that I want to use to hydrate a XML document).

The XML document looks like this:

xml
<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">

[code]....

View 2 Replies

Use Unmanaged C++ Dll In .net?

Jan 8, 2010

i need to pass commands through a C++ dll to vb.net and the other way around. is there some code that needs to be in the C++ dll to make it work? im not good at C++ at all,

View 5 Replies

Any Method Into Unmanaged Lua?

Oct 9, 2010

im trying to make a simple wrapper for lua. The only problem so far is that lua only accepts a method in a specific format.Delegate Function LuaC Function(ByVal lua_state As IntPtr) As Integer..That is how lua wants the method to look like. So it only accepts a function that looks like this: [code]

View 2 Replies

Use Dll In Unmanaged C++ Project?

Jan 5, 2010

I created a vb.net dll called "WSdll.dll".I compiled it, created a type library (tlb), and registered it globally(gacutil)..It includes a file called wsutils.vb, which includes a namespace called "wsutils".In the namespace, there's an interface (with attribute) called "IWSconnection", and a class called "WSconnection".The interface and class are public, as are all methods and properties.[code]...

View 2 Replies

.net - Load An Unmanaged DLL From A Stream?

May 18, 2012

I have an application written in .NET 4.0 that needs to load in memory a native DLL (written C). At the moment I am using a P/Invoke call to LoadLibrary passing the path where the DLL is located. This works, but due to the fact that this DLL comes from a DB, I would like to know if it is possible loading it through a stream, avoiding then the necessity to store the DLL somewhere in the filesystem.

View 2 Replies

Allow Calls From Unmanaged Code?

May 5, 2009

I have an application which has been succesfully installed on a number of different client machines.

The problem I now have is that I have been asked to allow third party applications, possibly written in a non .net language set to plug into my application and execute some of the code. Just a handfull of properties and half a dozen methods.

Now I can wrap up these properties/methods, make them public and have them in their own project which will be part of my solution but I have no idea where to go from here.

How do I make this portion of my application accessible to a third party application written in unmanaged code ?

View 1 Replies

C# - ASP.NET Load Unmanaged Dll From Bin Folder

May 25, 2010

Question: I use an embedded Firebird database in ASP.NET.

Now, Firebird has a .NET wrapper around native dlls.

The problem is, with the ASP.NET compilation and execution process, the dlls get shadow copied to a temporary folder. Unfortunately, only the .NET dlls, and not the native dll.

See [URL] for details.

Now, this makes it necessary to put the unmanaged dll somewhere into the system32 directory (or any other directory in the path environment variable).

Now, I want to change the wrapper/native dll (opensource), so it loads the dlls also if they are only in the bin folder.

Now, my problem is, how can I, in .NET, load an unmanaged dll from an absolute path ? The absolute path is determined at runtime, not at compile-time...

View 2 Replies

Call Function From An Unmanaged DLL?

Feb 17, 2010

I have an unmanaged DLL and need to call one of its functions. Here's the [code]...

View 5 Replies

Connect An Unmanaged DirectX To .NET?

Sep 20, 2009

Maybe this is not true ... But how to connect an unmanaged DirectX to VB.NET? For anyone dll I use <DllImport()>, but Unmaged DirectX have interface.... Than I tried use "<ComImport(), Guid(...)...>", but I do not know how to use COM interfaces Maybe I did not really understand COM technolgy... I tried find documentation "how to use com interfaces", but found nothing.

View 1 Replies

Function Calls To Unmanaged DLL From VB

Jun 12, 2009

I'm having some trouble finding the syntax for making function calls to unmanaged DLLs in VB.NET. Let's just assume there's a function "Connected" in unmanaged DLL "Connector.DLL". I want to call this function by creating an abstract function call to it.

I've seen some code out there that looks something like
[DllImport("Connector.DLL")]
Public Shared Function Connect(ByVal intPort)
But that syntax doesn't work for me.

View 2 Replies

Arraylist Of Structure Within Array Of Structure?

May 23, 2010

I want to make a structure within a structure. Basically it will appear like this:

Structure ID
dim CardType as string
im CardCode as string

[code]......

View 13 Replies

Assign Array Of Structure To Another Of Same Structure?

Oct 12, 2010

In Vb.net I am trying to assign an array of structure to another array of same structure[code]...

View 2 Replies

.net - P/Invoke BSTR From Unmanaged Code?

May 23, 2011

What should be the VB signature for the unmanaged function void PopulateBSTR(BSTR outstring)?The function PopulateBSTR does a SysAllocString and populates the string. Note the unmanagaed signature has the argument BSTR and not BSTR*. I can marshal the BSTR string using IntPtr signature when the C++ signature has BSTR* as the argument.

(The unmanaged code is an external dll which I cannot modify but I need to use.)

View 2 Replies







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