How To Access A DLL Function Having A Void Pointer Argument
Jan 4, 2012
I need to access a DLL function which has a void pointer argument (probably written in C/C++). In VB6 it could be accessed by declaring the argument as 'Any'. VB2008/VB2010 does not know this variable type 'Any'.
I tried instead: Object, IntPtr, UIntPtr, Int32(), Long e.t.c. but there always occurs a compile error or a runtime error.I did a lot of Internet investigation but could not find any answer.
I want my vb.net dll to get the data sent from c++ project(exe).Can any body help on in what form this void pointer can be sent via pipe. The void pointer corresponds to enums or structures. I have to get this structures/enums on the vb.net dll end. I have mentioned about using pipe. My question is as what type the pointed to data can be send over the pipe so that I can easily handle the received data at the vb.net dll end.
I want to pass the address of a sub as a callback to another method. From what I can find, a function is passed using the format:
Public Sub test(ByRef callback as Func(ArgClass, ReturnClass))
The thing is, as mentioned, I don't want to pass it a function but a sub. There doesn't seem to be an equivalent class Sub which will stand in place of Func, and it won't allow me to set the return class as nothing, so I'm somewhat stumped. How should this problem be solved?
I really need little help with unmanaged dll access from VB.NET, have been working on it about a week. I have a C++ .h files with headers. I have to access one function from the dll using VB.NET:
int acsGetEventPoll (int acsHandle, void FAR*eventBuf, unsigned short FAR*eventBufSize);
Documentation says that eventBuf is a buffer where structure of type CSTAEvent_t is put after the function call. Type is defined as:
Public Class Form1 Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As IntPtr Public Declare Function GetProcAddress Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As IntPtr, ByVal lpProcName As String) As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim hmod As IntPtr = GetModuleHandle(Nothing) 'Work Dim addrs As IntPtr = GetProcAddress(hmod , "TestFunction") 'Not work, always NULL why??
i being ordered to change my function skill to returning value by using struct but not using pointer. may i know what is the pro and con between this 2?
I am using visual basic and trying to create function. I am getting this error: "Argument not specified for parameter '_IsDayRateCheckBox' of private function CalculateParikingCharges(_HoursDecimal As Decimal, _IsDayRateCheckBox As System.Windows.Forms.CheckBox) As Decimal'.
This is the code. Private Function CalculateParkingCharges(ByVal _HoursDecimal As Decimal, ByVal _IsDayRateCheckBox As CheckBox) As Decimal
This is how I call the function. Dim HoursDecimal As Decimal Dim AmountOwedDecimal As Decimal If Not Decimal.TryParse(HoursTextBox.Text, HoursDecimal) OrElse HoursDecimal < 0D Then ErrorLabel.Visible = True HoursTextBox.Focus() [Code] .....
I have to create a program that finds the total cost for pizza, fries, and soft drinks, and places that in a list box. So far, though, I'm stuck. I have this code so far:
Public Class frmBill Private Sub btnTotal_Click(ByVal sender As System.Object, [Code] .....
The errors that I am getting are: "Argument not specified for parameter 'D' of Public Function totalBill(P As Double, F As Double, D As Double) "Argument not specified for parameter 'F' of Public Function totalBill(P As Double, F As Double, D As Double) "Argument not specified for parameter 'P' of Public Function totalBill(P As Double, F As Double, D As Double)"
How can I create a function that returns an object of a certain type, which the user of the function specify in the argument (using vb.net 2010) ?
[Code]...
The code above doesn't work, but maybe it can explain what I want to achieve. Using this feature, I want to hydrate my data transfer objects from datatable. Client will just call this function, specifying which DTO the client wants, and this function will just create that DTO and populating the properties with reflection GetType.GetProperties().
I have several parameters consisting of separate System.Byte() arrays. What I need is the syntax for a function declaration where the parameter is an array of arrays - I do not want to delve into System.Collections, and it's my preference not to CType each array into an Object and then back into a Byte().
Problem I'm having here is that:
Public Function MyFunc(arrayparam() As System.Byte) As System.Byte()
accepts a single-dimensional Array of individual Bytes.
Then Public Function MyFunc(arrayparam() As System.Byte()) As System.Byte()
VB.NET is not letting me dance with both feet, or piss with both hands. I've got one foot and one arm tied behind my back at every turn. I want to use this statement in a function: Return CType(Formatter.Deserialize(FS), DS) Seems doable, right?
Function ReadFileStream(ByRef FS As FileStream, ByRef DS As Object) Dim Formatter As New BinaryFormatter FS.Position = 0 Return CType(Formatter.Deserialize(FS), DS) End Function
Right? I mean, CType only accepts a class name as the second argument. I can't give it an instance of a class, or it croaks. Yet if I try to pass the class name as the argument to that function: DataInfo = ReadFileStream(FileStream1, DataStruct)
VB.NET croaks on this, too, complaining that "'DataStruct' is a type and cannot be used as an expression.". It's used as an expression by CType just fine outside of the function. Does the VB.NET legislature provide a clause that allows for a 'Type' to be passed as an argument in a function? Writing all the supporting code ten million times to deserialize a file using CType ten million times in a large application will get very complicated and tricky very quickly. It should be handled by a routine so that any cases and adjustments that come up can be dealt with in one spot.
I have an Excel VBA function that takes a number of optional parameters, including an optional Range: Function DazBeta(A As Range, Z As Range, _ B As Integer, _ Optional Freq As Integer = 1, _ Optional c As Double = 0, _ Optional r As Range, _ Optional Pct As Boolean = True, _ Optional Label As Integer = 1)
I am translating to VB.NET, and it's the optional Range that is giving me grief because VB.NET does allow optional Ranges. Or rather, optional parameters must provide a default value. What is the recommended way to change the VB.NET function signature so that the code is callable from an Excel cell as a UDF? (The VB.NET implements a UDF, the assembly is registered as a COM server, and the Excel spreadsheet is told of this server and type library, allowing the VB.NET code to be called from an Excel spreadsheet cell.) I have other compilation problems, so I have not been able to explore this. I am thinking that accepting an optional Object (default value Nothing) might work and then I could cast the Object to a Range. Alternatively, if there were a default value that could be specified with an optional Range, that would work, too.
Im a student doing an assignment, how do i pass the value from a sub procedure to a function procedure....i want to pass the value from decSubtotal to a function procedure named CalculateDiscount; check out my code--
What does this mean? This just started I never had this error.
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
I'm following along with an excellent Scott Guthrie article (MVC form posting scenarios) and trying to convert it to VB along the way. I've got everything working except one piece. At one point in the article he's adding his own business rules to a LINQ to SQL entity like this:
public partial class Product { partial void OnValidate(ChangeAction action)
Possible Duplicate: Convert Null to zero in access databaseI'm using Microsoft Visual Web Developer 2010 Express to create ASP/VB.NET page to connect with a Microsoft office Access 07. Here's my issue: