"Dave Griffin" <ca***********@yahoo.com> wrote in message
news:45*************************@posting.google.co m...
I have what I think is an "unmanaged DLL" that I access from within C#
using the construction:
[DllImport("sbslib32.dll")]
public static extern ushort sbs_init_device(ushort DevNum,
ushort queue_length, ushort bsm_length,
SBS1553Classes.SBS_FIRMWARE_SOURCE firmware_source);
There are no object oriented constructions here and the code is
actually C (not C++). I would like to create a "phony" version of this
DLL for use on our desktop machines (where the hardware this DLL uses
is not present) but I don't know how to do it in .NET or if it's even
possible. I would like to install it on the desktop and then use my
own implementation (my phony DLL) to pretend to feed data to my
program in order to construct non-trivial tests of throughput.
Is there a way to do this, and if so, can you point me to an example?
Sure
Visual Studio > New Project > Visual C++ Projects > Win32 Projects > Win32
Project
Brings up the "Win32 Application Wizard"
Change Application Settings > Application Type
Choose ApplicationType: DLL and Additional Options: Export Symbols
That will create a skeleton of an unmanaged DLL. In the [appname].h file
are the exports for the application, with examples of exporting a class,
variable and a function.
See generally
http://msdn.microsoft.com/library/de...from_a_dll.asp
Something like this:
struct SBS_FIRMWARE_SOURCE
{
int i;
};
extern "C" __declspec(dllexport)
unsigned short sbs_init_device(
unsigned short DevNum,
unsigned short queue_length,
unsigned short bsm_length,
SBS_FIRMWARE_SOURCE firmware_source);
If the function in uses the cdecl calling convention. For stdcall use
extern "C" __declspec(dllexport)
unsigned short __stdcall sbs_init_device(
unsigned short DevNum,
unsigned short queue_length,
unsigned short bsm_length,
SBS_FIRMWARE_SOURCE firmware_source);
But in the case of stdcall, you'll also need to use a .def file to name the
export because the compiler will name the exported function
"_sbs_init_device".
http://msdn.microsoft.com/library/de....def_files.asp
David