473,666 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help to marshall Win32 DLL call to VB.net

Hello

I've (in WinImage SDK http://www.winimage.com/wima_sdk.htm ) a function that
I need to use from a VB.Net apps

First, on the unmanaged Win32 DLL, I've a function which get the number of
item (function GetNbEntryCurDi r)
after, I allocate an array and I call GetDirInfo to fill the array
// GetNbEntryCurDi r : Get the number of entry of cur directory
DWORD WIMAAPI GetNbEntryCurDi r(HIMA hIma);
#define MAXLFN 256

typedef struct
{
char nom[8];
char ext[3];
char szCompactName[13];
BYTE bAttr;

BYTE dir_CreateMSec;
WORD dir_CreateDate;
WORD DosTime;
WORD DosDate;

BOOL fIsSubDir;
BOOL fSel; // for private use of client app.
BOOL fLfnEntry;
DWORD dwSize;
UINT uiPosInDir;
DWORD dwLocalisation;
DWORD dwTrueSize;
char longname[MAXLFN];
WORD dir_CreateTime;
WORD dir_LastAccessD ate;
} DIRINFO;
// GetDirInfo : Get info about the entry of cur directory
// LPDIRINFO : array of DIRINFO that will receive the info
// (use GetNbEntryCurDi r for know the size needed)
// bSort : specify how the file must be sort
// (SORT_NONE, SORT_NAME, SORT_EXT, SORT_SIZE or SORT_DATE)
BOOL WIMAAPI GetDirInfo(HIMA hIma,LPDIRINFO lpdi,BYTE bSort);

on C++ unmanager, I do:
{
HIMA hIma; // filled by other function
DWORD dwNumber = GetNbEntryCurDi r(hIma);
DIRINFO* pDirInfo = (DIRINFO*)mallo c(sizeof(DIRINF O) * dwNumber );
GetDirInfo(hIma ,pDirInfo,0);
DWORD i;
for (i=0;i<dwNumber ;i++) printf("%s\n", (pDirInfo+i)->longname)
}

I want do the same work on VB.net

I had converted DIRINFO structure on VB.net

Public Const MAXLFN As Short = 256

<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi, Pack:=1)_

Public Structure DIRINFO

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=8)Pu blic nom As String

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=3)Pu blic ext As String

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=13)P ublic szCompactName As
String

Public bAttr As Byte

Public dir_CreateMSec As Byte

Public dir_CreateDate As Short

Public DosTime As Short

Public DosDate As Short

Public fIsSubDir As Integer

Public fSel As Integer

Public fLfnEntry As Integer

Public dwSize As Integer

Public uiPosInDir As Integer

Public dwLocalisation As Integer

Public dwTrueSize As Integer

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=MAXL FN)Public longname As
String

Public dir_CreateTime As Short

Public dir_LastAccessD ate As Short

End Structure

I need help to convert VB Array to unmanaged C-Style array. I suppose I need
<MarshalAs(Unma nagedType.LPArr ay)or <MarshalAs(Unma nagedType.ByVal Array)>

I tried

Declare Function GetDirInfo Lib "wimadll.dl l" (ByVal Ima As Integer,
<MarshalAs(Unma nagedType.LPArr ay)ByRef dia As DIRINFO, ByVal bSort As
Byte) As Boolean

without success

Any help or tips will be a lot welcome !

regards

Gilles Vollant
Nov 24 '06 #1
2 4654
I found a (bad) solution

<StructLayout(L ayoutKind.Seque ntial)_

Public Structure DirInfoArrayStr uct

<MarshalAs(Unma nagedType.ByVal Array, SizeConst:=32)P ublic diItem As
DIRINFO()

End Structure

This solution is not very good :

- I must known how many item I'll have when I compile (here I put 32)

- when a high number of item, I've stack error
Nov 24 '06 #2
Hi,

"Gilles Vollant (MVP)" <in**@winimage. comwrote in message
news:Od******** ******@TK2MSFTN GP03.phx.gbl...
Hello

I've (in WinImage SDK http://www.winimage.com/wima_sdk.htm ) a function
that I need to use from a VB.Net apps

First, on the unmanaged Win32 DLL, I've a function which get the number of
item (function GetNbEntryCurDi r)
after, I allocate an array and I call GetDirInfo to fill the array
// GetNbEntryCurDi r : Get the number of entry of cur directory
DWORD WIMAAPI GetNbEntryCurDi r(HIMA hIma);
#define MAXLFN 256

typedef struct
{
char nom[8];
char ext[3];
char szCompactName[13];
BYTE bAttr;

BYTE dir_CreateMSec;
WORD dir_CreateDate;
WORD DosTime;
WORD DosDate;

BOOL fIsSubDir;
BOOL fSel; // for private use of client app.
BOOL fLfnEntry;
DWORD dwSize;
UINT uiPosInDir;
DWORD dwLocalisation;
DWORD dwTrueSize;
char longname[MAXLFN];
WORD dir_CreateTime;
WORD dir_LastAccessD ate;
} DIRINFO;
// GetDirInfo : Get info about the entry of cur directory
// LPDIRINFO : array of DIRINFO that will receive the info
// (use GetNbEntryCurDi r for know the size needed)
// bSort : specify how the file must be sort
// (SORT_NONE, SORT_NAME, SORT_EXT, SORT_SIZE or SORT_DATE)
BOOL WIMAAPI GetDirInfo(HIMA hIma,LPDIRINFO lpdi,BYTE bSort);

on C++ unmanager, I do:
{
HIMA hIma; // filled by other function
DWORD dwNumber = GetNbEntryCurDi r(hIma);
DIRINFO* pDirInfo = (DIRINFO*)mallo c(sizeof(DIRINF O) * dwNumber );
GetDirInfo(hIma ,pDirInfo,0);
DWORD i;
for (i=0;i<dwNumber ;i++) printf("%s\n", (pDirInfo+i)->longname)
}

I want do the same work on VB.net

I had converted DIRINFO structure on VB.net

Public Const MAXLFN As Short = 256

<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi, Pack:=1)_

Public Structure DIRINFO

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=8)Pu blic nom As String

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=3)Pu blic ext As String

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=13)P ublic szCompactName
As String

Public bAttr As Byte

Public dir_CreateMSec As Byte

Public dir_CreateDate As Short

Public DosTime As Short

Public DosDate As Short

Public fIsSubDir As Integer

Public fSel As Integer

Public fLfnEntry As Integer

Public dwSize As Integer

Public uiPosInDir As Integer

Public dwLocalisation As Integer

Public dwTrueSize As Integer

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=MAXL FN)Public longname As
String

Public dir_CreateTime As Short

Public dir_LastAccessD ate As Short

End Structure

I need help to convert VB Array to unmanaged C-Style array. I suppose I
need <MarshalAs(Unma nagedType.LPArr ay)or
<MarshalAs(Unma nagedType.ByVal Array)>

I tried

Declare Function GetDirInfo Lib "wimadll.dl l" (ByVal Ima As Integer,
<MarshalAs(Unma nagedType.LPArr ay)ByRef dia As DIRINFO, ByVal bSort As
Byte) As Boolean

Can't say i tested something like this recently, but you could try something
like:

Imports System.Runtime. InteropServices

Declare Function GetDirInfo Lib "wimadll.dl l" (ByVal Ima As Integer,
<[In](),Out()ByVal dia() As DIRINFO, ByVal bSort As Byte) As Boolean

HTH,
Greetings

>
without success

Any help or tips will be a lot welcome !

regards

Gilles Vollant


Nov 25 '06 #3

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

Similar topics

5
2511
by: nbotw | last post by:
Hi, I need a function call in my xml web service. I have an old win32 dll and i have created a class to have my declaration in. Imports System.Runtime.InteropServices Public Class Win32
4
2851
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to be loaded, which function to be called, and what are the parameters to call the function. Thank you very much!
4
2028
by: Gnanaprakash Rathinam | last post by:
Hi Expert, Is there a way to obtain assembly name in an unmanaged call? During Interop call between managed to unmanaged, I would like to know in unmanaged code about the caller of assembly file name? Thanks, GP.
5
4223
by: Eric BOUXIROT | last post by:
hi all !!! i need to call this API : FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD Flags) i have a sample code in C++ that work fine... > FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD Flags) >
2
4393
by: Sam Carleton | last post by:
I have a brain dead simple question: how in the heck do I call invoke in C++/CLI? I am simply doing a check to see if invoke needs to be called, but then I cannot for the world figure out how to actual call Invoke. Nor am I finding an examples anywhere. I know they are out there, but I simply am not finding them. Please help!!!!!! In C#: public delegate void OnStatusHandler(Object sender, StatusEventArgs args);
4
1431
by: Tami | last post by:
Hello, I could use some advice on the best way to connect to some php in my source code using ajax. So that the php will re-execute after so much time with a script elsewhere on the server. Please let me know, thanks. Tami
6
5118
by: HolyShea | last post by:
All, Not sure if this is possible or not - I've created a class which performs an asynchronous operation and provides notification when the operation is complete. I'd like the notification to be performed on the same thread thread that instantiated the class. One way to do this is to pass an ISynchronizeInvoke into the class and use it to synchronize the callback. In the constructor of the class, could I take note of the current thread...
6
6198
by: R.Kaiser | last post by:
I know that I can call Win32 API functions in a Windows forms application by specifying each function header individually like in using namespace System; using namespace System::Runtime::InteropServices; typedef void* HWND; extern "C" int* MessageBox(HWND hWnd, char* pText,
1
2158
by: Richard Gordon | last post by:
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting debug trace is: PythonWin 2.3.5 (#62, Feb 8 2005, 16:23:02) on win32.
0
8448
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.