have to "translate" / up-date a program that was written in C about 20 years ago to VB.net due to its old SQL connection style that isn't compatible anymore. However, I have minimal experience with C and even less with the winAPI(which the C application uses)... I was wondering, can the same functions from the API be use in VB.net?
I have been able to add a declaration like this:
to get a window Handle as IntPtr ( in vb.net). However the C program uses functions such as:
By importing the user32.dll I can't get the hWnd handle but I can get the IntPtr ( If I understood well, is a point to a window as an integer right? Kinda similar to hWnd --> I could be TOTALLY wrong, but this is what I understood)
As I go to the definition of each type (i.e: NEAR , HINSTANCE, LPCSTR, etc...) I try to find an equivalent call in VB but ... its useless. For instance, I've seen a lot of questions on google asking on how to get the HINSTANCE such as:
which does work in Visual Studio (no errors) BUT I need to create an object like this :
which is how the C code made it ( of course not with dim! haha)
Ultimately, my question is, would such call exist in vb.net / even be useful with the more modern framework and such?
I have been able to add a declaration like this:
Code:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Public Shared Function SetWindowText(hWnd As IntPtr, lpString As String) As Boolean
End Function
Code:
BOOL NEAR GoModal( HINSTANCE hInstance, LPCSTR lpszTemplate,HWND hWnd, DLGPROC lpDlgProc, LPARAM lParam )
As I go to the definition of each type (i.e: NEAR , HINSTANCE, LPCSTR, etc...) I try to find an equivalent call in VB but ... its useless. For instance, I've seen a lot of questions on google asking on how to get the HINSTANCE such as:
Code:
System.Runtime.InteropServices.Marshal.GetHINSTANCE _(System.Reflection.Assembly.GetExecutingAssembly.GetModules() _(0)).ToInt32()
Code:
Dim hinst as HINSTANCE
Ultimately, my question is, would such call exist in vb.net / even be useful with the more modern framework and such?
Comment