|
-
Oct 11th, 2001, 09:35 AM
#1
Thread Starter
Junior Member
Using a dll
Hello,
I'm trying to use a dll in a VB app. This dll as been written in C and can be used with a GUI made in Visual C++.
The fact is that I want to use only part of the dll's function in my app, so I don't want to be obliged to launch the GUI.
In my app, I've got a .bas with :
Public declare MyFunction lib "MyDll" (...)
In one of the function, I need to declare a variable which correspond in c to a cardinal, so :
- can someone tell me which is the corresponding variable in VB of a cardinal in c
- is declare ... lib "path of the dll" the right way to call for a dll
Thanks
Black Rose of the Artist Clan
-
Oct 11th, 2001, 02:34 PM
#2
Post the C declaration, and I'll try to translate it for you.
Also, here's a table that shows some of the common C declarations converted to VB.
Code:
BOOL Long
WORD Long
DWORD Long
BYTE Byte
LPSTR String
float Single
double Double
-
Oct 12th, 2001, 11:20 AM
#3
Thread Starter
Junior Member
Here is the stuff
Thanks Megatron,
here is the full procedure which I want to "copy" in VB
procedure TvStripForm.ParseIFO(FileName: String);
var
i, j: Integer;
ifo_handle, ifo_flags: Cardinal;
it: TTreeNode;
s: String;
begin
TreeViewIFO.Items.Clear();
IFOChainIdx := -1;
RadioGroupAngles.Items.Clear();
RadioGroupAngles.Enabled := False;
ListBoxIFOAudio.Items.Clear();
ListBoxIFOSub.Items.Clear();
for i := 0 to NumIFOChains - 1 do
if (IFOChains[i].Cells <> Nil) then begin
FreeMem(IFOChains[i].Cells);
IFOChains[i].Cells := Nil;
end;
SetLength(IFOChains, 0);
NumIFOChains := 0;
it := nil;
ifo_flags := 0;
case ComboBoxASPI.ItemIndex of
0: ifo_flags := ifo_flags + fio_USE_ASPI;
1: ifo_flags := ifo_flags + fio_USE_ASPI + vs_PREFER_ASPI;
end;
ifo_handle := ifoOpen(PChar(EditIFOName.Text), ifo_flags) ;
if (ifo_handle <> 0) then begin
j := ifoGetNumAudio(ifo_handle);
for i := 0 to j - 1 do
ListBoxIFOAudio.Items.Add(Format('%d. %s', [i, ifoGetAudioDesc(ifo_handle, i)]));
j := ifoGetNumSubPic(ifo_handle);
for i := 0 to j - 1 do
ListBoxIFOSub.Items.Add(Format('%d. %s', [i, ifoGetSubPicDesc(ifo_handle, i)]));
with TreeViewIFO.Items do begin
BeginUpdate();
NumIFOChains := ifoGetNumPGCI(ifo_handle);
SetLength(IFOChains, NumIFOChains);
for i := 0 to NumIFOChains - 1 do with IFOChains[i] do begin
NumCells := ifoGetPGCIInfo(ifo_handle, i, Length);
it := AddObject(nil, Format('%u. Length: %u:%.2u:%.2u:%.2u in %d cell(s)', [i, Length[0], Length[1], Length[2], Length[3], NumCells]), Pointer(i));
GetMem(Cells, NumCells * SizeOf(t_vs_vobcellid));
ifoGetPGCICells(ifo_handle, i, @Cells^[0]);
for j := 0 to NumCells - 1 do with Cells[j] do begin
s := Format('%u. V: %.3u/C: %.3u', [j, vob_id, cell_id]);
if (angle <> $11) then
s := s + Format(' (%u/%u)', [angle and $f, angle shr 4]);
s := s + Format(' [@LBA %u - %u]', [start_lba, end_lba]);
AddChildObject(it, s, Pointer(j));
end;
end;
if ((it <> nil) and (NumIFOChains = 1)) then
TreeViewIFO.Selected := it;
EndUpdate();
end;
ifoClose(ifo_handle);
end else
MessageDlg('vStrip could not read/parse the IFO-File', mtError, [mbOK], 0);
end;
In red, you have the function I can't cope with in VB. I guess that if I can have this one work, I'll have the others too.
for info, this is part of the source code of vSrtip, that you could find on the source code section of download section of http://www.doom9.org/
thanks for your help
Black Rose of the Artist Clan
-
Oct 12th, 2001, 02:31 PM
#4
That's Pascal, not C.
Anyways, if it's in the DLL, all you would need to convert it to a VB declaration is:
Code:
Private Declare Function MyFunc Lib "MyLib" Alias "ActualFunctionName" (ByVal Filename As String)
Use Dependancy Walker to get the "ActualFileName"
-
Oct 13th, 2001, 01:30 AM
#5
Thread Starter
Junior Member
OK
Thanks Megatron
As I know really nothing to C I supposed it was C.
So, I don't need to "convert" the second part of the call to the function ie ifoOpen(PChar(EditIFOName.Text), ifo_flags )
Thank you anyway
Black Rose of the Artist Clan
-
Oct 13th, 2001, 11:07 AM
#6
PChar looks like it's being used as a function, rather than a datatype.
Code:
PChar(EditIFOName.Text)
-
Oct 15th, 2001, 12:53 AM
#7
Thread Starter
Junior Member
That was so easy that I should have guess it by myself
Thank you a lot
Black Rose of the Artist Clan
-
Oct 15th, 2001, 10:03 AM
#8
Thread Starter
Junior Member
My version of VB (6) seems not to know PChar function...
Maybe I'm doing something wrong.
Black Rose of the Artist Clan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|