Passing Winapi 'HANDLE' Type Between VB & C Code

Feb 23, 2011

I have written some C/C++ code that uses the winapi functions CreateFile WriteFile SetFilePointer etc. to read & write some large (>4 GB) binary files. Some colleagues who are more familier with Visual basic than C, want to modify some of their existing code to call my C code functions.

I have turned my code into DLLs that I have successfully called from other C programs. I have also created a small C DLL that doesn't use the winapi functions & called it from a small VB program.

What I haven't so far been unable to do is pass the HANDLE type variable between a C function that uses the winapi functions & the VB program that call it so the VB can call another of my functions & pass the HANDLE.

In my attempt to do this, the declarations in the header file for two of the functions in the C DLL are:

[Code]...

When I step through the VB code in debug mode there is no problem with calling OpenSegyRW, but at WriteToSegy I get the error message:System.Runtime.InteropServices.MarshalDirectiveException was unhandled

Message=PInvoke restriction: cannot return variants.So what am I doing wrong & is there any way to pass the winapi HANDLE type between VB & C code? BTW indents etc. get lost when I paste my message into the forum. I hope this is decipherable.

View 3 Replies


ADVERTISEMENT

Sql - Passing Parameters To A Stored Proc Accepting In Parameter Of Type XML Type?

Jun 7, 2011

I have a storedproc accepts parameters in XMLtype as

CREATE OR REPLACE PROCEDURE GetDetails(
p_para IN XMLTYPE,

[code].....

View 1 Replies

C# - Override/Handle Own Type Conversions In .Net

Apr 20, 2011

Is there a way to define an implicit conversion operator in VB.NET?

I can't remember ever seeing or hearing of anyone do this; but now I'm in a situation where I think it would be incredibly useful to define my own custom 'type conversion' for my class.

As an example - let's say I have my own class, 'AwesomeDataManager'. It does not inherit from DataTable, but it holds data in a similar fashion to a DataTable. I would to be able to say, 'myDataTable = CType(MyAwesomeDataManager, DataTable)' and have it execute some code inside my class that would return a populated DataTable.

Granted, I could do something like 'MyAwesomeDataManager.GetDataTable' but for the sake of integrating with an existing code base, I'd like to avoid it.

View 2 Replies

IDE :: Handle The Events For This Type Of Objects?

Jan 15, 2009

I created a Class which inherits Combobox and the listview is added . Now what I need is once the user click listview, the listview has to close and the clicked item has to added with combobox text. simply can say combobox1.text = listview.item(0).textFor closing & displaying the listview I need to handle the events. For

My Codings :========Public Class Combu_lstviewInherits ComboBoxPrivate treeViewHost As ToolStripControlHostPrivate Shadows dropdown As ToolStripDropDownPublic mylistview As New ListView
Public Sub New()mylistview.BorderStyle = BorderStyle.Nonemylistview.View = View.Detailsmylistview.HeaderStyle =

[code].....

View 1 Replies

VS 2010 - Get Value Of Handle Without Knowing Type?

Dec 23, 2010

I am working on a new version of my clipboard manager. I was wondering if there would be a way to copy the value of a given handle without knowing its type? The current methods I know require one person to know the type of the handle (as an example by using Marshal.PtrToStructure).

View 1 Replies

Winapi - Send Key 46 (Chr(46)) With SendMessage?

Jun 14, 2012

I am Automating IBM iSeries Emulators using VB.net, created GUI that embeds the external iSeries Emulator Window in a WindowsForm Panel using the "SetParent" API .. To communicate with the iSeries Window I use the SendMessage API to send Key's to the Screen. I am aware of the sendkeys.keys in .net, but this way I dont have to SetForegroundWindow and reactivate my Form.

[Code]...

View 1 Replies

Forms :: How To Handle Each Variable Type Individually

Apr 11, 2010

I have defined 5 variables T1, T2, T3, T4, T5 As Double and set them all = 0. On a form I have a enter information button. Each time the button is pressed I want to assign a different variable, to a text box input. For instance, If I enter 1 that will become T1, and then if I enter 2 and press the button again, that value becomes T2.

I have tried
If T1 = 0 then
T1 = textbox.text
End if
If T1<>0 And T2 = 0 then
T2 = textbox.text
End if

I have tried to use 'else' statements and all kinds of things like that to no avail. I can get the first two variables correctly assigned but three is impossible with my current understanding. Is there a way to do this, or do I need 5 buttons, so that I can control which variable is assigned? To be correct my intent is to create an observation with three variables each time the button is pressed.

For example, the first button press will result in three variables being assigned a value other than 0; they are T1, B1, and R1. I have just begun to understand the concept of arrays and am wondering if that may be the way to go in this situation. I was just going at this in a newbie way I'm sure and trying to handle each variable type individually, and figure out all the T* variables and move onto the B* variables.

View 1 Replies

How To Handle Variable Type (parameter & Return Value)

May 25, 2011

Is it possible to replace these two functions

Function f1 (s As String) As class1()
Dim a() As String = Split(s)
Dim b(UBound(a)) As class1

[code].....

View 3 Replies

VS 2008 Handle Different Exceptions Of Same Exception Type?

Apr 11, 2012

Is there a way I can catch and handle two different exceptions within the same exception type? For example:

Try
' My code
Catch ex As System.Net.WebException
End Try

I have 2 different exceptions that are System.Net.WebException. I want to handle them different ways. Problem is the catch block above catches them both. Is there a way I can determine if which of the two it is and handle them differently?

View 3 Replies

VS 2008 Handle Same Event For All Of That Object Type?

Sep 12, 2009

Say I have a button that creates more buttons with a random .Text property, and placed them on the form in different locations. And since these buttons are being created at runtime, I want to be able to have an event handler for all button controls on the form that makes the form's text the same as the sender's text.

View 3 Replies

Passing A Type As An Argument?

Aug 12, 2010

I'm using VB.NET 2003 with .NET Framework v1.1. I know it's getting a bit old now but I'm stuck with an existing program and don't have the time/knowhow to convert it to anything newer.

My question would probably be solved very easily with Generics in .NET 2.0 but as I can't use that right now, I'd like to know if the following is possible:

I have a load of manager classes which inherit from DictionaryBase and hold collections of my custom classes. For example, I have a Employee class, a Batch class, a Supplier class, etc... and each of these has a Manager classwhich holds a collection of them - eg: my PlantTrayMgr class holds collections of PlantTrays, etc..

I have one particular form where I have to populate loads of comboboxes with the contents of various Manager objects. What I currently do in my form load event to populate comboboxes is this:

Code:
Option Strict On
Option Explicit On
Private _plantTrayMgr As PlantTrayMgr

[Code].....

View 4 Replies

C# - Arguments For CloseHandle() Winapi Call In .net

Aug 26, 2009

When accessing the winapi method CloseHandle() via .net P/Invoke, should the argument be IntPtr or HandleRef, and why?

View 2 Replies

Winapi - Closing A Modal Popup?

Dec 15, 2009

I want to wait for and close a modal form (a popup) from another application, as soon as it appears. I want to do this from VB.NET, but suggestions in C# should be easily translateable.

I can hard-code the modal popup's caption in my app, since it's long and unique. What I want to do is simulate either the user clicking on the close ("X") button on the form, or a click on the defeault, tab-order 0 button of the form. Either would work.

Maybe I need more info about the modal popup other than the title bar's caption? In any case, it's safe to use it as an unique identifier of that modal form. I also want that code to terminate checking as soon as the first event of closing the popup happens.

I believe it's trivial, but I can't find any ready info on that. Microsoft says I should not send WM_CLOSE to the modal popup, since it will call DestroyWindow() instead of EndDialog(), but to be honest I don't even know what "sending WM_CLOSE" to the "window" means =/

View 1 Replies

Hooking Another Program's Calls To Winapi Functions ?

Oct 22, 2010

I have been trying to build a game bot in vb.net.One of the main problems is getting access to the text the game prints on the screen so I have been trying to hook the games calls to the windows api drawtext and textout functions.I have been hunting for examples of how to set up a hook in vb.net for a long time without any luck.I have found it impossible to translate examples in old school vb, C++, and C#.For convenience's sake I would like to use the freely available deviare and/or easyhook libraries.

View 2 Replies

Win32 Handle That Was Passed To Icon Is Not Valid Or Is The Wrong Type

Jan 10, 2007

I was testing article [URL] to see if I could use this to populate a listview2 with the icons from Directory.GetFiles(apath) and getDirectories. If you go into c:windowssystem32 the program will hang for about 4 mins then if you go back to windows then back to system32 you will get the error.

win32 handle that was passed to icon is not valid or is the wrong type.

View 2 Replies

Passing Base Object Type When Using Inherited One?

Oct 8, 2010

I have a project that has mainly two objects, both inheriting from a base. Like this:

Public Class Vehicle
Property Model As String
Property Make As String[code].....

The above function doesn't work because myVehicle is a Vehicle, not a Truck.Is there a way I can pass around a Vehicle type and have the IDE know which type to use? Or am I completely missing a better way to do this?

View 5 Replies

Passing Parameter (Value Or Referenced Type) Into Method?

Nov 11, 2009

What happened when parameter passing. Here is a test project I write.
Public Class Form1
'1.test string
Private Sub btnString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnString.Click
Dim str1 As String = "x"
[Code] .....

From the project you can see, when pass integer type parameter (value type) into a method , if use ByVal keyword, the value won't change. If use ByRef keyword, the value will change (I can understand it, to my understanding, when using ByVal, It pass the value of the argument to the method; when using BvRef, it pass the address of the argument to the method, so the value can be rewrite)

Well, for the following two scenarios , I can't understand why.
String type is reference type, but it acts like integer type.
Val type is also reference type, but no matter what you use(ByVal or ByRef), the result will be the same.
So my question is what actually passed into method? What's the underlying mechanism about pass parameter? What's the effect of ByRef and ByVal to value type and reference type?

View 1 Replies

Reflection - Passing Values To Constructor Of Type T?

Jun 18, 2012

I have this code to get the default constructor:

Public Function f(ByVal t As System.Type) As Object
Return t.GetConstructor(New System.Type() {}).Invoke(New Object() {})
End Function

I need to pass values to the Constructor as

Public Function f(ByVal t As System.Type) As Object
Return t.GetConstructor(New System.Type() {someInteger,someString,etc.etc}).Invoke(New Object() {})
End Function

Also I have 3 classes of Type T, with all having different parametric constructor. It's important for me to have it generic as the Classes of type T might increase in future with less or more parameters.

View 1 Replies

Erroring When Passing Oracle Parameter Type PLSQLAssociativeArray

Jan 3, 2012

I have a oracle stored procedure that looks like:

[Code]...

View 1 Replies

Passing/Infering Type Through Shared Function Calls?

Dec 6, 2010

how to pass system.type or a generic without much luck. I have two functions below one that works and the other that doesn't. I can't seem to make heads or tails of the VB syntax required for doing what I want to do.

' This function does not
'
' Also attempted it like this

' Public Shared Function UnserializeFromJSON(ByVal obj As String, ByRef ty As System.type)[code].......

View 2 Replies

Sql - Passing Parameters To A StoredProc Accepting In Parameter Of XML Type?

Apr 8, 2010

I have a storedproc accepts parameters in XMLtype as

CREATE OR REPLACE PROCEDURE GetDetails(
p_para IN XMLTYPE,

i have to pass 4 parameters to this proc how to do this?

i am passing param as db.Parameters("p1", Oracle.DataAccess.Client.OracleDbType.Varchar2, _
' LN.Length, CObj(LN), Data.ParameterDirection.Input)

[code]....

View 4 Replies

Use WinAPI Recording And Playing Sound Without To Output To A File In VB Language?

Nov 19, 2007

I want to make a function to record the sound and then to play the record,like the telephone. I have ever download some articles,but they were all too complex,or they have too many unassociate code,so I can not understand the courses of the recording and playing.I want to get some code here?

View 2 Replies

WinAPI Click OK Remote Desktop Works Only When Window Is Active

Jun 8, 2012

I have a timer in winforms that looks for a specific OK dialog on my server (it clicks OK on a third party application that runs out of memory, then restarts it -- there is no other work around). So, when I remote desktop the server and the remote desktop window is active (the actual remote desktop window is active, not the actual window that has the OK that has to be clicked. I can have a window that has nothing to do with the OK, and it works), the program works as it should. It finds the window of the OK, then clicks the OK button fine. When I am not in remote destop, or when the remote desktop window is not active (or selecte) it finds the window and finds the OK button, but cannot click the OK button.

[Code]...

View 1 Replies

C# - .NET Generic Class Instance - Passing A Variable Data Type

Jun 2, 2010

I'm tyring to pass a variable data type to a template class. Something like this:

frmExample = New LookupForm(Of Models.MyClass) 'Works fine

Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine
frmExample = New LookupForm(Of SelectedType) 'Ba-bow!
frmExample = New LookupForm(Of InstanceOfMyClass.GetType()) 'Ba-bow!

[Code].....

I'm assuming it's something to do with the template being processed at compile time but even if I'm off the mark there, it wouldn't solve my problem anyway. I can't find any relevant information on using Reflection to instance template classes either.

(How) can I create an instance of a dynamically typed repository at runtime?

View 4 Replies

Add Some .net Code To Handle All The Errors In An Application?

Oct 4, 2009

is it possible to add some VB.net code to handle all the errors in my application. (and not to go in each sub and add the on error intruction) I want to handle every error.

View 6 Replies

C# - Better Pattern To Handle Nested Code Conditions?

Oct 28, 2010

I have a webpage that needs to selectively show or hide a substantial number of controls. Each control's visibility is determined based on which of 3 conditions are true.So, for example, given the conditions A, B, and C;

Control1 needs to be visible only when A and B are true and C is false.
Control2 needs to be visible only when B and C are true and A is false.
Control3 needs to be visible only when A and C are true and it doesn't care what B is.
and so on...

If each control looked at every condition, the control logic would be ugly, but doable.

[Code]...

View 2 Replies

Handle Null Values On One Line Of Code?

Mar 30, 2011

I need to round and print a price like below, but this does not handle null values.How can I handle null values on one line of code? DBRSet is an SQLDataReader and the price is money

<%= Math.Round(DBRSet("price"))%>

I have about 200 .aspx pages of this so I could also use some tips on how to change these in an easy way? Can I do a search and replace with a reg-exp or something like that?

View 2 Replies

Passing A Control To A Sub Rather Then Duplicate Code

Jan 10, 2011

Sorry about the bad title. Just wondering if it is possible to use a control name as parameters rather then doing the same code over and over again. Example.

[Code]...

View 7 Replies

Add A Code To Handle The TextChanged Event Of My Textboxes To Clear The Result Box?

Mar 17, 2009

add a code to handle the TextChanged event of my Textboxes to clear the Result box.

Private Sub btnCalculate_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
txtResult.Text = txtRate.Text / 100 * txtAmount.Text * txtYears.Text
End Sub

[code]....

View 2 Replies

Modify The Code Obtained From The Internet Explorer_Server HWND Handle?

Aug 22, 2011

code:
<span>Public Structure UUID
Public Data1 As Long
Public Data2 As Integer
Public Data3 As Integer
Private m_Data4() As Byte

[Code]...

View 1 Replies







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