NumXL SDK - Locality resources API
msg_init.cpp

This is an example program how to initialize and configure the SFMSG library More details about this example.

#include <windows.h>
#include <iostream>
#include <string>
#include "SFLOG.h"
#include "SFMSG.h"
int main(){
std::wstring szAppName = L"testapp";
std::wstring szLogDir =L"C:\\temp";
DWORD dwBackupFiles=7;
size_t ulMaxFileSize= (1024 * 1024); // 1 MB
unsigned int uLOGClientToken=0;
int nRetCode = SFLOG_INITW(szAppName.c_str(),szLogDir.c_str(), dwBackupFiles, ulMaxFileSize,&uLOGClientToken);
if(nRetCode == NDK_SUCCESS){
std::wcout << L" SUCCESS - Logging module is initialized" << std::endl;
szAppName = L"numxl_msg";
DWORD dwlcid = 1033; // US-EN MSFT locality Id
unsigned int uMSGClientToken = 0;
nRet = SFMSG_Init(szAppName.c_str(), NULL, dwlcid, &uMSGClientToken);
if(nRet == NDK_SUCCESS){
std::wcout << L" SUCCESS - locality module is initialized" << std::endl;
// Example 1: get the LCID
LCID dwDefLCId = 0;
nRet = SFMSG_LCID(&dwDefLCId);
// get the full path of the resource directory
std::wstring szPath;
size_t nLen = 0;
nRet = SFMSG_LCID_PATH(dwlcid, NULL, &nLen);
if(nRet == NDK_SUCCESS){
nLen++;
std::vector<TCHAR> szTmp(nLen, TCHAR(0));
nRet = SFMSG_LCID_PATH(dwlcid, &szTmp[0], &nLen);
szPath = &szTmp[0];
}
std::wcout << L" SUCCESS - locality resource path: " << szPath << std::endl;
std::wstring szResValue;
DWORD resId=100;
nLen=0;
nRet = SFMSG_MSG(resId, NULL, &nLen);
if(nRet == NDK_SUCCESS){
nLen++;
std::vector<TCHAR> szBuffer(nLen, TCHAR(0));
nRet = SFMSG_MSG(resId, &szBuffer[0] , &nLen);
szResValue =&szBuffer[0];
}
std::wcout << L" SUCCESS - locality resource (100) is: " << szResValue << std::endl;
nRet = SFMSG_Shutdown(uMSGClientToken);
}
nRet = SFLOG_SHUTDOWN(uLOGClientToken);
}
return 0;
}
#define NDK_SUCCESS
int __stdcall SFLOG_INITW(LPCWSTR szAppName, LPCWSTR szLogDir, DWORD dwBackupFiles, size_t ulMaxFileSize, unsigned int *pClientToken)
int __stdcall SFLOG_SHUTDOWN(unsigned int uClientToken)
int __stdcall SFMSG_MSG(DWORD resId, LPWSTR szBuffer, size_t *pSize)
Lookup and retrieve a localized string system.
Definition SFMSG.cpp:580
int __stdcall SFMSG_LCID(LPDWORD plcid)
returns the LCID of the currently selected language.
Definition SFMSG.cpp:155
int __stdcall SFMSG_Init(LPCWSTR szDllName, LPCWSTR szResDir, DWORD lcid, unsigned int *pClientToken)
Initialize the locality system.
Definition SFMSG.cpp:288
int __stdcall SFMSG_LCID_PATH(DWORD lcid, LPWSTR szPath, size_t *pSize)
Lookup and retrieve a the filepath used in our locality system.
Definition SFMSG.cpp:203
int __stdcall SFMSG_Shutdown(unsigned int uClientToken)
shutdown the locality system, and free resources.
Definition SFMSG.cpp:409