-
Notifications
You must be signed in to change notification settings - Fork 0
Home
little-brother edited this page Jul 17, 2024
·
7 revisions
The simplest way to learn it is check a code of existing plugins. Below some tips.
- Each plugin have to implement one function
HWND __stdcall view (HWND hParentWnd, const unsigned char* data, int dataLen, int dataType, TCHAR* outInfo16, TCHAR* outExt16)hParentWndis a dialog window handle.
data,dataLenanddataTyperepresent a value.dataTypeis one ofSQLITE_TEXTorSQLITE_BLOB. IfdataTypeequals toSQLITE_TEXTthendatacontains TCHAR/wchar_t-string.
outInfo16is an output string that will be shown in the left bottom corner. Max length is255.
outExt16defines a file extension when the value will be saved as a file e.g.txt.
- You can free resources in
int __stdcall close (HWND hPluginWnd)- function. - Plugins have a priority (high priority plugins are loaded first). To set the plugin priority implement
int __stdcall getPriority (). It's recommended to allow to user to change the priority via ini-file. - All standard plugins use ini-file to store their settings (often it has just a priority).
Typical ini-file for
plugin-nameis below (don't forget to provide a section):[plugin-name] priority=10 another-option=ABC - Keep in mind: Windows UI uses
UTF16LE(wchar_t). It means that each symbol is stored in 2 bytes. The recommended codepage for SQLite3 isUTF8where each symbol required 1-4 bytes. To convert betweemUTF16andUTF8you can use the next functions:
#define UNICODE
#define _UNICODE
...
TCHAR* utf8to16(const char* in) {
TCHAR *out;
if (!in || strlen(in) == 0) {
out = (TCHAR*)calloc (1, sizeof (TCHAR));
} else {
DWORD size = MultiByteToWideChar(CP_UTF8, 0, in, -1, NULL, 0);
out = (TCHAR*)calloc (size, sizeof (TCHAR));
MultiByteToWideChar(CP_UTF8, 0, in, -1, out, size);
}
return out;
}
char* utf16to8(const TCHAR* in) {
char* out;
if (!in || _tcslen(in) == 0) {
out = (char*)calloc (1, sizeof(char));
} else {
int len = WideCharToMultiByte(CP_UTF8, 0, in, -1, NULL, 0, 0, 0);
out = (char*)calloc (len, sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, in, -1, out, len, 0, 0);
}
return out;
}
...
TCHAR* str = utf8to16("Привет мир");
_tprintf(str); // do smth with UTF16-string
free(str); // release memory