C:\Program Files (x86)\Gatan\DMSDK\TemplatePlugIn\hello.cpp(49) : error C2664: 'LoadRoentecSpectrumDatabase' : cannot convert parameter 1 from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Hello coder777 and thanks for the tip.
I got a little further, now to
1 2 3 4 5 6
extern"C" __declspec(dllimport)long LoadRoentecSpectrumDatabase(char * argv);
long res;
char * pathname;
bool da = DM::OpenDialog( pathname );
res = LoadRoentecSpectrumDatabase(pathname);
it says:
hello.cpp
C:\Program Files (x86)\Gatan\DMSDK\TemplatePlugIn\hello.cpp(45) : warning C4700: local variable 'pathname' used without having been initialized
Linking...
Creating library Debug/TemplatePlugIn.lib and object Debug/TemplatePlugIn.exp
hello.obj : error LNK2001: unresolved external symbol __imp__LoadRoentecSpectrumDatabase
C:\Program Files (x86)\Gatan\DigitalMicrograph\PlugIns/TemplatePlugIn.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
i don't know what do to...
Does the char need to be a zero terminated character array for this to work? how would i try that?
pathname = pathname + '/0'
does not seem to do anything...
Don't know the first thing about visual c++ 6 (edit: nor Delphi :) ). What I know is that when you compile a DLL you get:
1. the DLL
2. a .lib file
The .lib file is the one that needs to be specified as an input to the linker, not the DLL. The DLL just has to be in the same folder as the .exe.
You might also want to check that everything's ok with your DLL by inspecting it with DependencyWalker (since it's extern C it will have a human readable name).
Does anybody know how to use Delphi languages "Packed record" in c++?
From the help file i have this function in Delphi:
1 2 3 4 5
// Read information from loaded database
function GetRoentecSpectrumDatabaseInfo(var DatabaseInfo:TRTDatabaseInfo;
PreviewImageBuffer:Pointer;var ImageBufferSize:LongInt;
SpectrumBuffer:Pointer;var SpectrumBufferSize:LongInt):LongInt;stdcall external
'rtspectrumlib.dll';
In the example this is used like this:
1 2 3 4 5 6 7
var Info : TRTDatabaseInfo;
Info.Version:=1;
Info.Size:=SizeOf(Info);
// Read database info without preview image and spectrum
ImgBufferSize:=0;
SpcBufferSize:=0;
res:=GetRoentecSpectrumDatabaseInfo(Info,nil,ImgBufferSize,nil,SpcBufferSize);
Also from help:
1 2 3 4 5 6 7 8 9 10
// Database info structure
TRTDatabaseInfo = packed record
Version : LongInt;
Size : LongInt;
ImageWidth : LongInt;
ImageHeight : LongInt;
ImageChannels : LongInt;
ActiveDetectors : LongInt;
MaxChannelCount : LongInt;
end;
Has anybody any experience about this?
What is this "nil"?