473,398 Members | 2,525 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,398 software developers and data experts.

Converting a vb application

SM
Hello group,
we are converting a VB6 application, written by other
people, for .NET Framework.
Original application depends on a DLL written in standard C.

The application communicates with an external device
using serial API functions located on the DLL.
Original developer write a VB function which makes a
call located in the DLL passing the instance and a function
pointer to a VB function. The DLL code creates an
invisible window with CreateWindow() function using
instance handle and function pointer (as WndProc,just
to handle a custom WM_xxx message).

Until the code was VB6/C code, it was OK.
Now, the code is, with a little modifications, VB.NET
and we receive an INVALID_HANDLE error on
CreateWindow() function.
I suppose the problem is on HINSTACE handle, cause
the VB.NET function used as WndProc receive a couple of
standard messages (WM_NCCREATE/WM_NCDESTROY).

We need to leave 'untouched' the DLL (now unmanaged).

How can we solve ?
Is it possible to use the VB.NET HINSTANCE in the same
way of the old VB HINSTANCE to create a new window in
a C ?

Thanks a lot,
regards
--
Stefano Mora
email: *@*
(remove *)

Nov 20 '05 #1
2 2328
"SM" <st**********@hotmail.com> schrieb
Hello group,
we are converting a VB6 application, written by other
people, for .NET Framework.
Original application depends on a DLL written in standard C.

The application communicates with an external device
using serial API functions located on the DLL.
Original developer write a VB function which makes a
call located in the DLL passing the instance and a function
pointer to a VB function. The DLL code creates an
invisible window with CreateWindow() function using
instance handle and function pointer (as WndProc,just
to handle a custom WM_xxx message).

Until the code was VB6/C code, it was OK.
Now, the code is, with a little modifications, VB.NET
and we receive an INVALID_HANDLE error on
CreateWindow() function.
I suppose the problem is on HINSTACE handle, cause
the VB.NET function used as WndProc receive a couple of
standard messages (WM_NCCREATE/WM_NCDESTROY).

We need to leave 'untouched' the DLL (now unmanaged).

How can we solve ?
Is it possible to use the VB.NET HINSTANCE in the same
way of the old VB HINSTANCE to create a new window in
a C ?


This should work:

Imports System.Reflection
Imports System.Runtime.InteropServices

'...
Private Function GetHInstance() As IntPtr
Dim Assy As [Assembly]
Dim Modules As [Module]()

Assy = [Assembly].GetExecutingAssembly
Modules = Assy.GetModules
If Modules.Length > 0 Then 'rarely 0
Return Marshal.GetHINSTANCE(Modules(0))
End If

End Function

I don't know if this solves the mentioned problem and there might be other
approaches, but it should return the HInstance. :-)

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Hi,

You need to use a delegate for callback functions. Hope this
helps.

http://www.elitevb.com/content/01,0075,01/04.aspx

http://msdn.microsoft.com/library/de...classtopic.asp

Ken
--------------
"SM" <st**********@hotmail.com> wrote in message
news:uU**************@tk2msftngp13.phx.gbl...
Hello group,
we are converting a VB6 application, written by other
people, for .NET Framework.
Original application depends on a DLL written in standard C.

The application communicates with an external device
using serial API functions located on the DLL.
Original developer write a VB function which makes a
call located in the DLL passing the instance and a function
pointer to a VB function. The DLL code creates an
invisible window with CreateWindow() function using
instance handle and function pointer (as WndProc,just
to handle a custom WM_xxx message).

Until the code was VB6/C code, it was OK.
Now, the code is, with a little modifications, VB.NET
and we receive an INVALID_HANDLE error on
CreateWindow() function.
I suppose the problem is on HINSTACE handle, cause
the VB.NET function used as WndProc receive a couple of
standard messages (WM_NCCREATE/WM_NCDESTROY).

We need to leave 'untouched' the DLL (now unmanaged).

How can we solve ?
Is it possible to use the VB.NET HINSTANCE in the same
way of the old VB HINSTANCE to create a new window in
a C ?

Thanks a lot,
regards
--
Stefano Mora
email: *@*
(remove *)

Nov 20 '05 #3

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

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Derek Martin | last post by:
Hi there, kind of a dumb question, but it falls in line with not understanding (go figure) every nuance about .Net. Is it relatively straight forward to convert a VB.Net built app to an ASP.Net...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
32
by: robert d via AccessMonster.com | last post by:
I'm looking at converting DAO to ADO in my app. All of my DAO connections are of the following structure: Dim wsName As DAO.Workspace Dim dbName As DAO.Database Dim rsName As DAO.Recordset ...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
1
by: SLC via DBMonster.com | last post by:
Hello I'm a newbie to this and I need help, please My question is, we currently have a IDMS db and will be converting to DB2. What are the things I should do? The IDMS has not been documented very...
6
by: ll | last post by:
Hi, I'm currently working with a 'classic ASP' intranet site which uses a SQL server and am looking for possible ways to market it as an application for certain medical fields. Where would be a...
1
by: =?Utf-8?B?SG93YXJkIFBpbnNsZXk=?= | last post by:
I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at "Converting a Web Site Project to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.