Supporting Unicode in a Plugin
Moderators: Hacker, petermad, Stefan2, white
Supporting Unicode in a Plugin
Hi,
I've tried to modify the fs_samplePlugin sources to unicode by:
- define UNICODE and _UNICODE
- modified all the char to _TCHAR
- modified all non unicode functions like strcpy, strcmp to its unicode compliant version
- modied both fsplugin.h and fsplugin.cpp exported function that are called by TC
It compiles fine and TC can load the unicode plugin, but it displays an "A" as the plugin name in the Network Neighborhood and plugin doesn't work.
I know that TC is not unicode, and it calls the fs exported functions with non unicode variables and that's what it is confusing me.
Is it possible to make an UNICODE plugin or not?
I am using VS2005.
I've tried to modify the fs_samplePlugin sources to unicode by:
- define UNICODE and _UNICODE
- modified all the char to _TCHAR
- modified all non unicode functions like strcpy, strcmp to its unicode compliant version
- modied both fsplugin.h and fsplugin.cpp exported function that are called by TC
It compiles fine and TC can load the unicode plugin, but it displays an "A" as the plugin name in the Network Neighborhood and plugin doesn't work.
I know that TC is not unicode, and it calls the fs exported functions with non unicode variables and that's what it is confusing me.
Is it possible to make an UNICODE plugin or not?
I am using VS2005.
______________________
David Jorge
Personal License #117854
David Jorge
Personal License #117854
I'm trying to convert the FS sample plugin to UNICODE. I'm only using the mandatory interface.
The interface remains the same (non unicode), and i'm using the new ATL7.0 conversion objects. I can't get the plugin to work with my changes.
The FNC loop returns: "A","B","C","D","E" instead of "A:","B:","C:","D:","E:".
I'm using the folowing conversion objects CA2T, CW2A, CW2A.
The code is exactly the same of the sample plugin, with minor changes to support unicode. I conver unicode strings back to ansi whenever i have to return something to TC.
What i'm doing wrong?
The interface remains the same (non unicode), and i'm using the new ATL7.0 conversion objects. I can't get the plugin to work with my changes.
The FNC loop returns: "A","B","C","D","E" instead of "A:","B:","C:","D:","E:".
I'm using the folowing conversion objects CA2T, CW2A, CW2A.
The code is exactly the same of the sample plugin, with minor changes to support unicode. I conver unicode strings back to ansi whenever i have to return something to TC.
What i'm doing wrong?
Code: Select all
HANDLE __stdcall FsFindFirst(char* Path,WIN32_FIND_DATA *FindData)
{
CA2T TPath(Path);
TCHAR buf[MAX_PATH];
pLastFindStuct lf;
memset(FindData,0,sizeof(WIN32_FIND_DATA));
if (_tcscmp(TPath,_T("\\"))==0) {
FindData->dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY;
FindData->ftLastWriteTime.dwHighDateTime=0xFFFFFFFF;
FindData->ftLastWriteTime.dwLowDateTime=0xFFFFFFFE;
lf=(pLastFindStuct)malloc(sizeof(tLastFindStuct));
CW2A aPath(TPath);
strcpy(lf->Path,aPath);
lf->searchhandle=INVALID_HANDLE_VALUE;
TCHAR ch='A';
_tcscpy(buf,_T("A:\\"));
while (GetDriveType(buf)==DRIVE_NO_ROOT_DIR && ch<'Z'+1) {
ch++;
buf[0]=ch;
}
buf[2]=0;
if (ch<='Z') {
CW2A aBuf(buf);
strcpy(lf->LastFoundName,aBuf);
_tcscpy(FindData->cFileName,buf);
return (HANDLE)lf;
} else {
free(lf);
return INVALID_HANDLE_VALUE;
}
} else {
_tcscpy(buf,TPath+pluginrootlen);
_tcscat(buf,_T("\\*.*"));
HANDLE hdnl=FindFirstFile(buf,FindData);
if (hdnl==INVALID_HANDLE_VALUE)
return INVALID_HANDLE_VALUE;
else {
lf=(pLastFindStuct)malloc(sizeof(tLastFindStuct));
CW2A aBuf(buf);
strcpy(lf->Path,aBuf);
lf->searchhandle=hdnl;
return (HANDLE)lf;
}
}
return INVALID_HANDLE_VALUE;
}
BOOL __stdcall FsFindNext(HANDLE Hdl,WIN32_FIND_DATA *FindData)
{
TCHAR buf[MAX_PATH];
pLastFindStuct lf;
if ((int)Hdl==1)
return false;
lf=(pLastFindStuct)Hdl;
if (lf->searchhandle==INVALID_HANDLE_VALUE) { // drive list!
TCHAR ch=lf->LastFoundName[0];
_tcscpy(buf,_T("A:\\"));
buf[0]=ch+1;
while (GetDriveType(buf)==DRIVE_NO_ROOT_DIR && ch<'Z'+1) {
ch++;
buf[0]=ch;
}
buf[2]=0;
if (ch<='Z') {
CW2A aBuf(buf);
strcpy(lf->LastFoundName,aBuf);
_tcscpy(FindData->cFileName,buf);
return true;
} else {
return false;
}
} else {
lf=(pLastFindStuct)Hdl;
BOOL ret = FindNextFile(lf->searchhandle,FindData);
return ret;
}
return false;
}
______________________
David Jorge
Personal License #117854
David Jorge
Personal License #117854
- ghisler(Author)
- Site Admin
- Posts: 50421
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
The name is returned in WIN32_FIND_DATA. Total Commander expects a WIN32_FIND_DATAA, while you assume a WIN32_FIND_DATAW. You need to copy the data from the Unicode struct to an Ansi struct and convert the file name accordingly too.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com