Hate to give you the news...
I've been experimenting with c++ dlls for vb. I currently use msvc++ to make them but anyone that has the capabilities should be fine. There is probably a different format in different compilers; I'm just now learning this and so I use msvc and a good book called "C++ For Vb Programmers" which explains also the making of a dll file for vb. First off, you need a .DEF file (i think needs to be the same name as .cpp file) with the following format:
------beginning of .def format sample--------------
LIBRARY (the dll filename)
DESCRIPTION "Description for the dll; I think this is optional"
EXPORTS
Function1
Function2
-----------end of sample---------------
Then you need a .cpp file(in vc++ there should be one already made with some code already in it)
the format for creating functions inside the cpp file for the dll are as follows:
---------beginning-----
long APIENTRY Function1(int num1, int num2) {
long NewVar;
NewVar num1 * num2 / (num2 - num1) + num1;
return NewVar;
}
---end---------
in the first line, the 'long' specifies what type of variable it's returning, if any; APIENTRY needs to come right afterwards; and the Function1 needs to be the same as in the DEF file. The num1 and num2 need to be provided in the call from VB as example:
----in a vb module------
Public Declare Function AlterNums Lib "Dllfile" Alias "Function1" (num1, num2) As Long
---------------
The AlterNums is the name of the function to use inside vb so you could do this:
AlterNums 21, 5
AlterNums Var1, Var2
and the "Function1" is the name of the function inside the dll file. If the Name inside the dll file is the same as the name to use inside Vb, it will remove the Alias to become:
Public Declare Function Function1 Lib "Dllfile" (num1, num2) As Long
However, I've been told you can not use interrupts inside the dll because they are DOS interrupts and can not be called in windows. However, you can use the asm block in cpp
_asm {
// CPP comments and Asm comments allowed
/*However, you will most likely get errors in the inline assembly. I forget what kind, but it's when using varibles inside the asm. If you do get the problems, email me and I'll give you a link to MSDN where they show corrections*/
}
Sorry, now I look at it, looks more like C++
Got this at the Operating Systems Resource Center
//***************START****************
#include <bios.h>
#include <stdio.h>
void main()
{
FILE *in;
unsigned char buffer[520];
if((in = fopen("bootsect", "rb"))==NULL)
{
printf("Error loading file\n");
exit(0);
}
fread(&buffer, 512, 1, in);
while(biosdisk(3, 0, 0, 0, 1, 1, buffer));
fclose(in);
}
//*************END****************************