本文整理汇总了C++中StringCchPrintfA函数的典型用法代码示例。如果您正苦于以下问题:C++ StringCchPrintfA函数的具体用法?C++ StringCchPrintfA怎么用?C++ StringCchPrintfA使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringCchPrintfA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScriptManager
Dialog* Dialog::createDialogByScript( const char* dialogName )
{
char tempBuf[256];
Tcl_Interp* interp = GetScriptManager().getInterp();
StringCchPrintfA( tempBuf, 256, "%s::region", dialogName );
TileRegion region;
GetScriptManager().readRect( tempBuf, region );
StringCchPrintfA( tempBuf, 256, "%s::dialog", dialogName );
Tcl_Obj* dialogObj = GetScriptManager().getObject( tempBuf );
int dialogTokenCount;
Tcl_ListObjLength( interp, dialogObj, &dialogTokenCount );
UINT speakCount = dialogTokenCount / 2;
Dialog::Speak* speakArray = new Dialog::Speak[ speakCount ];
UINT i;
for ( i = 0; i < speakCount; ++i )
{
Tcl_Obj* elem;
int length;
Tcl_ListObjIndex( interp, dialogObj, i*2 + 0, &elem );
speakArray[ i ].name = Tcl_GetStringFromObj( elem, &length );
Tcl_ListObjIndex( interp, dialogObj, i*2 + 1, &elem );
speakArray[ i ].content = Tcl_GetStringFromObj( elem, &length );
}
StringCchPrintfA( tempBuf, 256, "%s::oneTime", dialogName );
int oneTime = GetScriptManager().readInt( tempBuf );
return new Dialog( speakArray, speakCount, ®ion, oneTime?true:false, dialogName );
}
示例2: loadWorldModel
HRESULT World::init()
{
HRESULT hr = S_OK;
if ( GetG().m_videoMan->GetDev() )
loadWorldModel();
char command[128];
StringCchPrintfA( command, 128, "%s::init 0x%p", m_worldName.c_str(), this );
GetScriptManager().execute( command );
if ( !m_sound )
{
m_sound = new Sound;
m_sound->init();
}
else
throw std::runtime_error( "Sound should not be init twice or more" );
// 'enter' function implemented in the script file defines which characters are exist in this world
char scriptCommand[128];
StringCchPrintfA( scriptCommand, 128, "%s::enter", m_worldName.c_str() );
GetScriptManager().execute( scriptCommand );
// Hero and enemies are defined afterwards
// CAUTION To be set by RakNet ReplicaManager
assert( m_heroUnit );
m_curDialog = 0;
return hr;
}
示例3: GetSockOptDecode
ULONG
GetSockOptDecode(
IN PBTR_FILTER_RECORD Record,
IN ULONG MaxCount,
OUT PWCHAR Buffer
)
{
PSK_GETSOCKOPT Data;
CHAR Value[MAX_PATH];
if (Record->ProbeOrdinal != _getsockopt) {
return S_FALSE;
}
Data = (PSK_GETSOCKOPT)Record->Data;
if (Data->optname == SO_LINGER) {
StringCchPrintfA(Value, MAX_PATH, "%d:%d", Data->OptionValue[0], Data->OptionValue[1]);
}
else if (Data->OptionLength <= sizeof(int)) {
StringCchPrintfA(Value, MAX_PATH, "%d", *(int *)&Data->OptionValue[0]);
}
else {
Value[0] = 0;
}
StringCchPrintf(Buffer, MaxCount - 1,
L"socket=%d, level=%d, optname=%d, optval=0x%p (%S), optlen=0x%p (%d), return=%d, LastErrorStatus=0x%08x",
Data->sk, Data->level, Data->optname, Data->optval, Value, Data->optlen, Data->OptionLength,
Data->ReturnValue, Data->Status);
return S_OK;
}
示例4: Dutil_Trace
/*******************************************************************
Dutil_Trace
*******************************************************************/
extern "C" void DAPI Dutil_Trace(
__in LPCSTR szFile,
__in int iLine,
__in REPORT_LEVEL rl,
__in LPCSTR szFormat,
...
)
{
AssertSz(REPORT_NONE != rl, "REPORT_NONE is not a valid tracing level");
HRESULT hr = S_OK;
char szOutput[DUTIL_STRING_BUFFER];
char szMsg[DUTIL_STRING_BUFFER];
if (Dutil_rlCurrentTrace < rl)
return;
va_list args;
va_start(args, szFormat);
hr = StringCchVPrintfA(szOutput, countof(szOutput), szFormat, args);
va_end(args);
if (SUCCEEDED(hr))
{
LPCSTR szPrefix = "Trace/u";
char szMsg[DUTIL_STRING_BUFFER];
switch (rl)
{
case REPORT_STANDARD:
szPrefix = "Trace/s";
break;
case REPORT_VERBOSE:
szPrefix = "Trace/v";
break;
case REPORT_DEBUG:
szPrefix = "Trace/d";
break;
}
if (Dutil_fTraceFilenames)
hr = StringCchPrintfA(szMsg, countof(szMsg), "%s [%s,%d]: %s\r\n", szPrefix, szFile, iLine, szOutput);
else
hr = StringCchPrintfA(szMsg, countof(szMsg), "%s: %s\r\n", szPrefix, szOutput);
if (SUCCEEDED(hr))
OutputDebugStringA(szMsg);
// else fall through to the case below
}
if (FAILED(hr))
{
if (Dutil_fTraceFilenames)
StringCchPrintfA(szMsg, countof(szMsg), "Trace [%s,%d]: message too long, skipping\r\n", szFile, iLine);
else
StringCchPrintfA(szMsg, countof(szMsg), "Trace: message too long, skipping\r\n");
OutputDebugStringA(szMsg);
}
}
示例5: IsModuleLoaded
void IsModuleLoaded(PCTSTR pszModuleName) {
HMODULE hmod = GetModuleHandle(pszModuleName);
char sz[100];
#ifdef UNICODE
StringCchPrintfA(sz, _countof(sz), "Module \"%S\" is %Sloaded.",
pszModuleName, (hmod == NULL) ? L"not " : L"");
#else
StringCchPrintfA(sz, _countof(sz), "Module \"%s\" is %sloaded.",
pszModuleName, (hmod == NULL) ? "not " : "");
#endif
chMB(sz);
}
示例6: GetSockNameDecode
ULONG
GetSockNameDecode(
IN PBTR_FILTER_RECORD Record,
IN ULONG MaxCount,
OUT PWCHAR Buffer
)
{
PSK_GETSOCKNAME Data;
CHAR Address[MAX_PATH];
if (Record->ProbeOrdinal != _getsockname) {
return S_FALSE;
}
Data = (PSK_GETSOCKNAME)Record->Data;
if (Data->name) {
StringCchPrintfA(Address, MAX_PATH - 1, "%S:%d",
inet_ntoa(Data->Name.sin_addr), ntohs(Data->Name.sin_port));
} else {
Address[0] = 0;
}
StringCchPrintf(Buffer, MaxCount - 1,
L"socket=%d, name=0x%p (%S), namelen=0x%p (%d), return=%d, LastErrorStatus=0x%08x",
Data->sk, Data->name, Address, Data->namelen, Data->NameLength, Data->ReturnValue, Data->Status);
return S_OK;
}
示例7: GetHostByAddrDecode
ULONG
GetHostByAddrDecode(
IN PBTR_FILTER_RECORD Record,
IN ULONG MaxCount,
OUT PWCHAR Buffer
)
{
PSK_GETHOSTBYADDR Data;
CHAR Host[MAX_PATH];
IN_ADDR addr;
if (Record->ProbeOrdinal != _gethostbyaddr) {
return S_FALSE;
}
Data = (PSK_GETHOSTBYADDR)Record->Data;
addr.s_addr = *(u_long *)Data->Host.h_addr_list[0];
StringCchPrintfA(Host, MAX_PATH, "%s:%s", Data->Host.h_name, inet_ntoa(addr));
StringCchPrintf(Buffer, MaxCount - 1,
L"addr=0x%p (%S), len=%d, type=%d, return=0x%p (%S), LastErrorStatus=0x%08x",
Data->addr, Data->Address, Data->len, Data->type, Data->ReturnValue, Host, Data->Status);
return S_OK;
}
示例8: AVMPI_getFunctionNameFromPC
bool AVMPI_getFunctionNameFromPC(uintptr_t pc, char *buffer, size_t bufferSize)
{
#ifdef UNDER_CE
(void)pc;
(void)buffer;
(void)bufferSize;
return false;
#else
if(!InitDbgHelp())
return false;
// gleaned from IMAGEHLP_SYMBOL64 docs
IMAGEHLP_SYMBOL64 *pSym = (IMAGEHLP_SYMBOL64 *) alloca(sizeof(IMAGEHLP_SYMBOL64) + MaxNameLength);
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
pSym->MaxNameLength = MaxNameLength;
DWORD64 offsetFromSymbol;
if(!g_DbgHelpDll.m_SymGetSymFromAddr64 ||
!(*g_DbgHelpDll.m_SymGetSymFromAddr64)(GetCurrentProcess(), pc, &offsetFromSymbol, pSym)) {
return false;
}
StringCchPrintfA(buffer, bufferSize, "%s", pSym->Name);
//printf("%s\n", pSym->Name);
return true;
#endif //UNDER_CE
}
示例9: write
//////////////////////////////////////////////////////////////////////////////////////////
// RtfWriter::write
//! Writes a character to the stream
//!
//! \param[in] ch - The character
//!
//! \throw wtl::logic_error - [Debug only] Writer has been closed
//! \throw wtl::domain_error - I/O error occurred
//////////////////////////////////////////////////////////////////////////////////////////
void write(element_t ch)
{
element_t buf[10];
// Check stream is open
if (Closed)
throw wtl::logic_error(HERE, "Writer is closed");
// Escape/Convert char:
switch (ch)
{
case '{':
case '}':
writeChar('\\');
writeChar(ch);
break;
case '\\': writeString("\\\\"); break;
case '\n': writeString("\\line "); break;
case '\t': writeString("\\tab "); break;
default:
// ANSI char:
if (ch <= 0x7f)
writeChar(ch);
else
{ // UNICODE char:
StringCchPrintfA(buf, 10, "\\u%u?", (uint32_t)ch);
writeString(buf);
}
break;
}
}
示例10: setForeColour
//////////////////////////////////////////////////////////////////////////////////////////
// RtfWriter::setForeColour
//! Sets the text colour
//!
//! \param[in] c - The colour
//!
//! \throw wtl::invalid_argument - Unrecognised colour
//! \throw wtl::logic_error - [Debug only] Writer has been closed
//! \throw wtl::domain_error - I/O error occurred
//////////////////////////////////////////////////////////////////////////////////////////
void setForeColour(COLORREF c)
{
CHR buf[10];
// Check stream is open
if (Closed)
throw wtl::logic_error(HERE, "Writer is closed");
// Skip if colour already set
if (ForeColour == c)
return;
// Lookup colour ID
for (UINT id = 0; id < Colours.size(); id++)
if (Colours[id] == c)
{ // Write colour change
StringCchPrintfA(buf, 10, "\\cf%d ", id + 1);
writeString(buf);
ForeColour = c;
return;
}
// Unknown colour
throw wtl::invalid_argument(HERE, "No such colour in the colour table");
}
示例11: RenderFrame
///--- AICI FACE RENDER ---
void RenderFrame(double dTime)
{
long i;
float scrX,scrY;
long x1,y1,x2,y2;
baloons.paintBaloons(&buffer);
//--- draw mouse cursor ---
if(g_bLmouseButt)
{
buffer.line(g_ptMouse.x - 5, g_ptMouse.y , g_ptMouse.x + 4, g_ptMouse.y , 0, 180, 0);
buffer.line(g_ptMouse.x , g_ptMouse.y - 5, g_ptMouse.x, g_ptMouse.y + 4, 0, 180, 0);
}
else
{
buffer.line(g_ptMouse.x - 6, g_ptMouse.y , g_ptMouse.x + 5, g_ptMouse.y , 0, 255, 0);
buffer.line(g_ptMouse.x , g_ptMouse.y - 6, g_ptMouse.x, g_ptMouse.y + 5, 0, 255, 0);
}
///--- draw FPS ---
char fpstxt[MAX_PATH];
StringCchPrintfA(fpstxt, MAX_PATH, "FPS: %d dTime:%.5f", fps, dTime);
buffer.drawText(0, 0, fpstxt, 0x00ff00ff);
}
示例12: DbgPrintEntry
ULONG __cdecl
DbgPrintEntry(
__in PCHAR Format,
...
)
{
PDBG_OUTPUTA Filter;
PBTR_FILTER_RECORD Record;
BTR_PROBE_CONTEXT Context;
DBGPRINT Routine;
size_t Length;
ULONG UserLength;
va_list arg;
PULONG_PTR Sp;
ULONG Result;
char format[512];
char buffer[512];
BtrFltGetContext(&Context);
Routine = Context.Destine;
//
// N.B. Maximum support 16 arguments
//
Sp = (PULONG_PTR)&Format + 1;
Result = (*Routine)(Format, Sp[0], Sp[1], Sp[2], Sp[3], Sp[4],
Sp[5], Sp[6], Sp[7], Sp[8], Sp[9],
Sp[10], Sp[11], Sp[12], Sp[13], Sp[14]);
BtrFltSetContext(&Context);
__try {
va_start(arg, Format);
StringCchVPrintfA(format, 512, Format, arg);
StringCchPrintfA(buffer, 512, "%s", format);
Length = strlen(buffer) + 1;
va_end(arg);
UserLength = FIELD_OFFSET(DBG_OUTPUTA, Text[Length]);
Record = BtrFltAllocateRecord(UserLength, DbgUuid, _DbgPrint);
if (!Record) {
return Result;
}
Filter = FILTER_RECORD_POINTER(Record, DBG_OUTPUTA);
Filter->Length = Length;
StringCchCopyA(Filter->Text, Length, buffer);
BtrFltQueueRecord(Record);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
if (Record) {
BtrFltFreeRecord(Record);
}
}
return Result;
}
示例13: WSAConnectDecode
ULONG
WSAConnectDecode(
IN PBTR_FILTER_RECORD Record,
IN ULONG MaxCount,
OUT PWCHAR Buffer
)
{
PSK_WSACONNECT Data;
CHAR Address[MAX_PATH];
if (Record->ProbeOrdinal != _WSAConnect) {
return S_FALSE;
}
Data = (PSK_WSACONNECT)Record->Data;
if (Data->name) {
StringCchPrintfA(Address, MAX_PATH - 1, "%S:%d",
inet_ntoa(Data->Address.sin_addr), ntohs(Data->Address.sin_port));
} else {
Address[0] = 0;
}
StringCchPrintf(Buffer, MaxCount - 1,
L"socket=%d, name=0x%p (%S), namelen=%d, lpCallerData=0x%p, lpCalleeData=0x%p,"
L"lpSQOS=0x%p, lpGQOS=0x%p, return=%d, LastErrorStatus=0x%08x",
Data->sk, Data->name, Address, Data->namelen, Data->lpCallerData,
Data->lpCalleeData, Data->lpSQOS, Data->lpGQOS, Data->ReturnValue, Data->Status);
return S_OK;
}
示例14: WSAAcceptDecode
ULONG
WSAAcceptDecode(
IN PBTR_FILTER_RECORD Record,
IN ULONG MaxCount,
OUT PWCHAR Buffer
)
{
PSK_WSAACCEPT Data;
CHAR Address[MAX_PATH];
if (Record->ProbeOrdinal != _WSAAccept) {
return S_FALSE;
}
Data = (PSK_WSAACCEPT)Record->Data;
if (Data->addr) {
StringCchPrintfA(Address, MAX_PATH - 1, "%S:%d",
inet_ntoa(Data->Address.sin_addr), ntohs(Data->Address.sin_port));
} else {
Address[0] = 0;
}
StringCchPrintf(Buffer, MaxCount - 1,
L"socket=%d, addr=0x%p (%S), addrlen=0x%p (%d), lpfnCondition=0x%p, dwCallbackData=0x%d,"
L"return=%d, LastErrorStatus=0x%08x",
Data->sk, Data->addr, Address, Data->addrlen, Data->AddressLength,
Data->ReturnValue, Data->Status);
return S_OK;
}
示例15: FileGroupDelete
DWORD FileGroupDelete(INT32 groupId)
{
CHAR *path;
CHAR buffer[12];
DWORD result;
ASSERT(groupId != -1);
TRACE("groupId=%d", groupId);
// Retrieve group file location
StringCchPrintfA(buffer, ELEMENT_COUNT(buffer), "%i", groupId);
path = Io_ConfigGetPath("Locations", "Group_Files", buffer, NULL);
if (path == NULL) {
TRACE("Unable to retrieve file location.");
return ERROR_NOT_ENOUGH_MEMORY;
}
// Delete group file and free resources
if (DeleteFileA(path)) {
result = ERROR_SUCCESS;
} else {
result = GetLastError();
TRACE("Unable to delete file \"%s\" (error %lu).", path, result);
}
Io_Free(path);
return result;
}