WDX content plugin in C, need help
Moderators: Hacker, petermad, Stefan2, white
WDX content plugin in C, need help
Hi,
I'm new on forum.
I want to make some plugins for my work. Already got code in C, but now I have to make a WDX plugin (for custom column).
Could someone give me a simple example WDX plugin.
For example, plugin that
- accept only *.txt files (I have to implement ContentGetDetectString)
- return 1 if filename is a.txt
- custom column name is "test"
I've already read contentplugin.HLP help file.
I have to implement those functions
ContentGetSupportedField
ContentGetValue
and ContentGetDetectString (for .txt files).
But now I have no idea ... what do I have to do, a .dll file and rename it to wdx?
Please give me a push with simple example. I really want to make some plugins.
thanks a lot.
greetings!
I'm new on forum.
I want to make some plugins for my work. Already got code in C, but now I have to make a WDX plugin (for custom column).
Could someone give me a simple example WDX plugin.
For example, plugin that
- accept only *.txt files (I have to implement ContentGetDetectString)
- return 1 if filename is a.txt
- custom column name is "test"
I've already read contentplugin.HLP help file.
I have to implement those functions
ContentGetSupportedField
ContentGetValue
and ContentGetDetectString (for .txt files).
But now I have no idea ... what do I have to do, a .dll file and rename it to wdx?
Please give me a push with simple example. I really want to make some plugins.
thanks a lot.
greetings!
Why not use the official sample?
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
- ghisler(Author)
- Site Admin
- Posts: 50479
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Just try the sample, it's mostly plain C, not C++. Only minor modifications should be necessary to compile it with an ANSI C compiler.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Yes, just rename it. Or you can even leave it as DLL, it does not matter.bampkej wrote:what should I do then, rename it to wdx or ?
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
Using TC 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
If I test dll with WDXtest plugin, I get
Plugin libtcfilesys.dll loaded.
Plugin does not imlement ContentGetDetectString()
Plugin does not imlement ContentPluginUnloading()
Plugin does not imlement ContentSetDefaultParams()
Error: plugin does not imlement mandatory ContentGetSupportedField()
how do I propertly export those functions ?
Plugin libtcfilesys.dll loaded.
Plugin does not imlement ContentGetDetectString()
Plugin does not imlement ContentPluginUnloading()
Plugin does not imlement ContentSetDefaultParams()
Error: plugin does not imlement mandatory ContentGetSupportedField()
how do I propertly export those functions ?
Thanks for info.
Still same problem
I've used:
Here is source:
http://www.megafileupload.com/en/file/22812/wdx-src-zip.html
Thanks[/code]
Still same problem

I've used:
Code: Select all
__declspec(dllexport) int __stdcall ContentGetValue(char* FileName,int FieldIndex,int UnitIndex,void* FieldValue,int maxlen,int flags)
http://www.megafileupload.com/en/file/22812/wdx-src-zip.html
Thanks[/code]
I probably need to export it with that .def file.
I've checked exported functions with fileinfo plugin and they have strange names, like
_Z15ContentGetValuePciiPvii@24
Can someone tell me how to add that .def file to linker.
I'm using eclipse + MinGW
Only setting that I've found under MinGW C++ linker - Shared Library options is :
Def file name (-Wl,--output-def=):
but if I set that one, it generates def file and not use it as input for renaming functions.
help please
I've checked exported functions with fileinfo plugin and they have strange names, like
_Z15ContentGetValuePciiPvii@24
Can someone tell me how to add that .def file to linker.
I'm using eclipse + MinGW
Only setting that I've found under MinGW C++ linker - Shared Library options is :
Def file name (-Wl,--output-def=):
but if I set that one, it generates def file and not use it as input for renaming functions.
help please

- ghisler(Author)
- Site Admin
- Posts: 50479
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
A quick Google search brought me here:
http://www.geocities.com/yongweiwu/stdcall.htm
CL can accept a DEF file on the command line, and it simply passes the file name to LINK. E.g.,
cl /LD testdll.obj testdll.def
will become
link /out:testdll.dll /dll /implib:testdll.lib /def:testdll.def testdll.obj
http://www.geocities.com/yongweiwu/stdcall.htm
CL can accept a DEF file on the command line, and it simply passes the file name to LINK. E.g.,
cl /LD testdll.obj testdll.def
will become
link /out:testdll.dll /dll /implib:testdll.lib /def:testdll.def testdll.obj
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Thanks for help.
Now I've exported functions with extern "C" __declspec(dllexport).
I can load plugin without error, but when I want to add custom column, total commander crashes (Access violation at address ...).
Here is simple code that I've used:
Any idea what is wrong ?
Thanks
Now I've exported functions with extern "C" __declspec(dllexport).
I can load plugin without error, but when I want to add custom column, total commander crashes (Access violation at address ...).
Here is simple code that I've used:
Code: Select all
#include "stdafx.h"
#include "contentplug.h"
#define fieldcount 1
char* fieldnames[fieldcount]={"title"};
int fieldtypes[fieldcount]={ft_string};
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
char* strlcpy(char* p,const char* p2,int maxlen)
{
if ((int)strlen(p2)>=maxlen) {
strncpy(p,p2,maxlen);
p[maxlen]=0;
} else
strcpy(p,p2);
return p;
}
extern "C" __declspec(dllexport) int ContentGetSupportedField(int FieldIndex,char* FieldName,char* Units,int maxlen)
{
if (FieldIndex<0 || FieldIndex>=fieldcount)
return ft_nomorefields;
strlcpy(FieldName,fieldnames[FieldIndex],maxlen-1);
return fieldtypes[FieldIndex];
}
extern "C" __declspec(dllexport) int ContentGetValue(char* FileName,int FieldIndex,int UnitIndex,void* FieldValue,int maxlen,int flags)
{
switch (FieldIndex) {
case 0:
strlcpy((char*)FieldValue,(char*)"test",maxlen-1);
break;
default:
return ft_nosuchfield;
}
return fieldtypes[FieldIndex];
}
Thanks
- ghisler(Author)
- Site Admin
- Posts: 50479
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
To my knowledge, these functions will have the C calling convention: The caller must remove the variables from the stack. Windows and Total Commander, however, use the stdcall calling convention, where the function itself removes the local variables from the stack. Therefore you get a crash.
Try defining the functions like this:
int __stdcall ContentGetSupportedField(int FieldIndex,char* FieldName,char* Units,int maxlen)
Then create a file yourproject.def which contains a list of all the exported functions:
EXPORTS
ContentGetSupportedField
Try defining the functions like this:
int __stdcall ContentGetSupportedField(int FieldIndex,char* FieldName,char* Units,int maxlen)
Then create a file yourproject.def which contains a list of all the exported functions:
EXPORTS
ContentGetSupportedField
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com