当前位置: 首页>>代码示例>>C++>>正文


C++ StringCchCopyA函数代码示例

本文整理汇总了C++中StringCchCopyA函数的典型用法代码示例。如果您正苦于以下问题:C++ StringCchCopyA函数的具体用法?C++ StringCchCopyA怎么用?C++ StringCchCopyA使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringCchCopyA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: server_create

static int server_create(
    IN const struct server_info *info,
    OUT nfs41_server **server_out)
{
    int status = NO_ERROR;
    nfs41_server *server;

    server = calloc(1, sizeof(nfs41_server));
    if (server == NULL) {
        status = GetLastError();
        eprintf("failed to allocate server %s\n", info->owner);
        goto out;
    }

    StringCchCopyA(server->scope, NFS4_OPAQUE_LIMIT, info->scope);
    StringCchCopyA(server->owner, NFS4_OPAQUE_LIMIT, info->owner);
    InitializeSRWLock(&server->addrs.lock);
    nfs41_superblock_list_init(&server->superblocks);

    status = nfs41_name_cache_create(&server->name_cache);
    if (status) {
        eprintf("nfs41_name_cache_create() failed with %d\n", status);
        goto out_free;
    }
out:
    *server_out = server;
    return status;

out_free:
    free(server);
    server = NULL;
    goto out;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:33,代码来源:nfs41_server.c

示例2: nonzero

/*++

Io_GroupRename

    Renames an existing group.

Arguments:
    memory      - Pointer to an IO_MEMORY structure allocated by Io_ShmAlloc. The
                  buffer size must be large enough to hold the DC_RENAME structure.

    groupName   - Pointer to a null-terminated string that specifies an
                  existing group name.

    newName     - Pointer to a null-terminated string that specifies the new
                  name for the group.

Return Values:
    If the function succeeds, the return value is nonzero (true).

    If the function fails, the return value is zero (false). To get extended
    error information, call GetLastError.

--*/
BOOL
STDCALL
Io_GroupRename(
    IO_MEMORY *memory,
    const char *groupName,
    const char *newName
    )
{
    DC_RENAME *dcRename;

    // Validate arguments.
    if (memory == NULL || groupName == NULL || newName == NULL) {
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    // Check if the shared memory block is large enough.
    if (memory->size < sizeof(DC_RENAME)) {
        SetLastError(ERROR_INSUFFICIENT_BUFFER);
        return FALSE;
    }

    // Initialise the DC_RENAME structure.
    dcRename = (DC_RENAME *)memory->block;
    StringCchCopyA(dcRename->tszName,    ARRAYSIZE(dcRename->tszName),    groupName);
    StringCchCopyA(dcRename->tszNewName, ARRAYSIZE(dcRename->tszNewName), newName);

    if (!Io_ShmQuery(memory, DC_RENAME_GROUP, 5000)) {
        return TRUE;
    }

    SetLastError(ERROR_INVALID_GROUPNAME);
    return FALSE;
}
开发者ID:MalaGaM,项目名称:nxscripts,代码行数:57,代码来源:group.c

示例3: server_addrs_add

static void server_addrs_add(
    IN OUT struct server_addrs *addrs,
    IN const netaddr4 *addr)
{
    /* we keep a list of addrs used to connect to each server. once it gets
     * bigger than NFS41_ADDRS_PER_SERVER, overwrite the oldest addrs. use
     * server_addrs.next_index to implement a circular array */

    AcquireSRWLockExclusive(&addrs->lock);

    if (multi_addr_find(&addrs->addrs, addr, NULL)) {
        dprintf(SRVLVL, "server_addrs_add() found existing addr '%s'.\n",
            addr->uaddr);
    } else {
        /* overwrite the address at 'next_index' */
        StringCchCopyA(addrs->addrs.arr[addrs->next_index].netid,
            NFS41_NETWORK_ID_LEN+1, addr->netid);
        StringCchCopyA(addrs->addrs.arr[addrs->next_index].uaddr,
            NFS41_UNIVERSAL_ADDR_LEN+1, addr->uaddr);

        /* increment/wrap next_index */
        addrs->next_index = (addrs->next_index + 1) % NFS41_ADDRS_PER_SERVER;
        /* update addrs.count if necessary */
        if (addrs->addrs.count < addrs->next_index)
            addrs->addrs.count = addrs->next_index;

        dprintf(SRVLVL, "server_addrs_add() added new addr '%s'.\n",
            addr->uaddr);
    }
    ReleaseSRWLockExclusive(&addrs->lock);
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:31,代码来源:nfs41_server.c

示例4: notifyData

SystemTrayService::Handle SystemTrayServiceWindows::AddIcon(const RF_Draw::TrayIcon& Settings)
{
    // early exit if there are too many icons registered
    if(m_PImpl->m_IconData.Count() > MAX_WM_APP - WM_APP)
        return 0;

    RF_Mem::AutoPointer<NOTIFYICONDATA> notifyData(new NOTIFYICONDATA);

    RF_SysMem::Set(notifyData.Get(), 0, sizeof(NOTIFYICONDATA));
    notifyData->cbSize = sizeof(NOTIFYICONDATA);
    notifyData->hWnd = m_PImpl->m_HWND;
    notifyData->uVersion = NOTIFYICON_VERSION_4;
    notifyData->uFlags = NIF_GUID | NIF_MESSAGE;
    notifyData->uCallbackMessage = WM_APP + m_PImpl->m_IconData.Count();
    CoCreateGuid(&notifyData->guidItem);

    if(!Settings.Notification.IsEmpty())
    {
        notifyData->uFlags |= NIF_INFO | NIF_SHOWTIP;
        StringCchCopyA(notifyData->szInfo, ARRAYSIZE(notifyData->szInfo), Settings.Notification.c_str());
    }

    if(!Settings.Tooltip.IsEmpty())
    {
        notifyData->uFlags |= NIF_TIP;
        StringCchCopyA(notifyData->szTip, ARRAYSIZE(notifyData->szTip), Settings.Tooltip.c_str());
    }

    RF_IO::File icon;
    icon.SetLocation(Settings.Icon);
    if(icon.Exists())
    {
        RF_Type::String systemPath = Settings.Icon.GetComponents(RF_IO::UriComponents::Path);        
        int min = GetSystemMetrics(SM_CXSMICON);
        notifyData->hIcon = (HICON)LoadImage(NULL, systemPath.c_str(), IMAGE_ICON, 
                                             min, min, LR_LOADFROMFILE);
        if(notifyData->hIcon != 0)
        {
            notifyData->uFlags |= NIF_ICON;
        }
    }

    Handle handle = 0;
    SystemTrayService::Handle result = Shell_NotifyIcon(NIM_ADD, notifyData.Get());
    if(result)
    {
        handle = reinterpret_cast<Handle>(notifyData.Get());
        
        m_PImpl->m_IconData.Resize(m_PImpl->m_IconData.Count() + 1);
        auto& item = m_PImpl->m_IconData(m_PImpl->m_IconData.Count() - 1);
        m_PImpl->m_MessageLookup[notifyData->uCallbackMessage] = &item;
        m_PImpl->m_HandleLookup[handle] = &item;
        
        item.m_MenuHandle = m_PImpl->AddPopupMenu(Settings);
        item.m_NotificationData = notifyData;
    }

    return handle;
}
开发者ID:wangscript,项目名称:RadonFramework,代码行数:59,代码来源:SystemTrayServiceWindows.cpp

示例5: user_cache_copy

static void user_cache_copy(
    struct list_entry *lhs,
    const struct list_entry *rhs)
{
    struct idmap_user *dst = list_container(lhs, struct idmap_user, entry);
    const struct idmap_user *src = list_container(rhs, const struct idmap_user, entry);
    StringCchCopyA(dst->username, VAL_LEN, src->username);
    StringCchCopyA(dst->principal, VAL_LEN, src->principal);
    dst->uid = src->uid;
    dst->gid = src->gid;
    dst->last_updated = src->last_updated;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:12,代码来源:idmap.c

示例6: fillTypeAndModuleName

//------------------------------------------------------------------------------
// Function: fillTypeAndModuleName
//
// Description:
//
//  Utility to fetch and populate the type and module names of a typed object.
//
// Parameters:
//
// Returns:
//
//  HRESULT.
//
// Notes:
//
static _Check_return_ HRESULT
fillTypeAndModuleName(
	_In_ DbgScriptHostContext* hostCtxt,
	_In_ ULONG typeId,
	_In_ UINT64 moduleBase,
	_Out_ DbgScriptTypedObject* typObj)
{
	HRESULT hr = S_OK;
	const char* cachedTypeName = nullptr;
	const char* cachedModName = nullptr;

	// Get type name.
	//
	const ModuleAndTypeId modAndTypeId = { typeId, moduleBase };
	cachedTypeName = GetCachedTypeName(
		hostCtxt,
		modAndTypeId);
	if (!cachedTypeName)
	{
		hr = E_FAIL;
		hostCtxt->DebugControl->Output(
			DEBUG_OUTPUT_ERROR,
			ERR_FAILED_GET_TYPE_NAME);
		
		goto exit;
	}
	hr = StringCchCopyA(STRING_AND_CCH(typObj->TypeName), cachedTypeName);
	assert(SUCCEEDED(hr));
	
	// Get module name.
	//
	cachedModName = GetCachedModuleName(
		hostCtxt,
		moduleBase);
	if (!cachedModName)
	{
		hr = E_FAIL;
		hostCtxt->DebugControl->Output(
			DEBUG_OUTPUT_ERROR,
			ERR_FAILED_GET_MODULE_NAME);
		
		goto exit;
	}

	hr = StringCchCopyA(STRING_AND_CCH(typObj->ModuleName), cachedModName);
	assert(SUCCEEDED(hr));
	
exit:
	return hr;
}
开发者ID:alexbudmsft,项目名称:dbgscript,代码行数:65,代码来源:dstypedobject.cpp

示例7: nfs41_idmap_uid_to_name

int nfs41_idmap_uid_to_name(
    struct idmap_context *context,
    uid_t uid,
    char *name,
    size_t len)
{
    UINT_PTR uidp = uid; /* convert to pointer size to pass as void* */
    struct idmap_lookup lookup = { ATTR_UID, CLASS_USER, TYPE_INT, uid_cmp };
    struct idmap_user user;
    int status;

    dprintf(IDLVL, "--> nfs41_idmap_uid_to_name(%u)\n", uid);

    lookup.value = (const void*)uidp;

    /* look up the user entry */
    status = idmap_lookup_user(context, &lookup, &user);
    if (status) {
        dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
            "failed with %d\n", uid, status);
        goto out;
    }

    if (FAILED(StringCchCopyA(name, len, user.username))) {
        status = ERROR_BUFFER_OVERFLOW;
        eprintf("username buffer overflow: '%s' > %u\n",
            user.username, len);
        goto out;
    }

    dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
        "returning '%s'\n", uid, name);
out:
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:35,代码来源:idmap.c

示例8: config_defaults

/* parse default values from g_options[] into idmap_config */
static int config_defaults(
    struct idmap_config *config)
{
    const struct config_option *option;
    const int count = ARRAYSIZE(g_options);
    char *dst;
    int i, status = NO_ERROR;

    for (i = 0; i < count; i++) {
        option = &g_options[i];
        dst = (char*)config + option->offset;

        if (option->type == TYPE_INT) {
            if (!parse_uint(option->def, (UINT*)dst)) {
                status = ERROR_INVALID_PARAMETER;
                eprintf("failed to parse default value of %s=\"%s\": "
                    "expected a number\n", option->key, option->def);
                break;
            }
        } else {
            if (FAILED(StringCchCopyA(dst, option->max_len, option->def))) {
                status = ERROR_BUFFER_OVERFLOW;
                eprintf("failed to parse default value of %s=\"%s\": "
                    "buffer overflow > %u\n", option->key, option->def,
                    option->max_len);
                break;
            }
        }
    }
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:32,代码来源:idmap.c

示例9: nfs41_idmap_gid_to_group

int nfs41_idmap_gid_to_group(
    struct idmap_context *context,
    gid_t gid,
    char *name,
    size_t len)
{
    UINT_PTR gidp = gid; /* convert to pointer size to pass as void* */
    struct idmap_lookup lookup = { ATTR_GID, CLASS_GROUP, TYPE_INT, gid_cmp };
    struct idmap_group group;
    int status;

    dprintf(IDLVL, "--> nfs41_idmap_gid_to_group(%u)\n", gid);

    lookup.value = (const void*)gidp;

    /* look up the group entry */
    status = idmap_lookup_group(context, &lookup, &group);
    if (status) {
        dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
            "failed with %d\n", gid, status);
        goto out;
    }

    if (FAILED(StringCchCopyA(name, len, group.name))) {
        status = ERROR_BUFFER_OVERFLOW;
        eprintf("group name buffer overflow: '%s' > %u\n",
            group.name, len);
        goto out;
    }

    dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
        "returning '%s'\n", gid, name);
out:
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:35,代码来源:idmap.c

示例10: MspWriteLogEntry

VOID
MspWriteLogEntry(
	IN ULONG ProcessId,
	IN MSP_LOG_LEVEL Level,
	IN PSTR Format,
	...
	)
{
	ULONG IsLogging;
	va_list Argument;
	PMSP_LOG_ENTRY Entry;
	CHAR Buffer[MSP_LOG_TEXT_LIMIT];

	IsLogging = InterlockedCompareExchange(&MspLogObject.Flag, 0, 0);
	if (!IsLogging) {
		return;
	}

	va_start(Argument, Format);
	StringCchVPrintfA(Buffer, MAX_PATH, Format, Argument);
	va_end(Argument);

	Entry = (PMSP_LOG_ENTRY)MspMalloc(sizeof(MSP_LOG_ENTRY));
	Entry->ProcessId = ProcessId;

	GetLocalTime(&Entry->TimeStamp);
	StringCchCopyA(Entry->Text, MSP_LOG_TEXT_LIMIT, Buffer);

	EnterCriticalSection(&MspLogObject.Lock);
	InsertTailList(&MspLogObject.ListHead, &Entry->ListEntry);
	MspLogObject.ListDepth += 1;
	LeaveCriticalSection(&MspLogObject.Lock);

	return;
}
开发者ID:John-Chan,项目名称:dprobe,代码行数:35,代码来源:msplog.c

示例11: StringCchCopyA

std::vector<std::string> *listFilesDir(const char* dir) {
    WIN32_FIND_DATAA ffd;
	HANDLE hFind = INVALID_HANDLE_VALUE;
	char szDir[MAX_PATH];
    int arg_length;
	std::vector<std::string> *files_dir = new std::vector<std::string>();
    
    arg_length= (int)strlen(dir);

    if (arg_length > (MAX_PATH - 3))
        return files_dir;

    StringCchCopyA(szDir, MAX_PATH, dir);
    StringCchCatA(szDir, MAX_PATH, "\\*");

    hFind = FindFirstFileA(szDir, &ffd);

    if (INVALID_HANDLE_VALUE == hFind)
        return files_dir;
        
    do {
         files_dir->push_back(ffd.cFileName);
    } while (FindNextFileA(hFind, &ffd) != 0);
    
    FindClose(hFind);
    return files_dir;
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:27,代码来源:segren.cpp

示例12: switch

HRESULT __stdcall BtrfsContextMenu::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax) {
    if (ignore)
        return E_INVALIDARG;
    
    if (idCmd != 0)
        return E_INVALIDARG;
    
    switch (uFlags) {
        case GCS_HELPTEXTA:
            if (LoadStringA(module, bg ? IDS_NEW_SUBVOL_HELP_TEXT : IDS_CREATE_SNAPSHOT_HELP_TEXT, pszName, cchMax))
                return S_OK;
            else
                return E_FAIL;
            
        case GCS_HELPTEXTW:
            if (LoadStringW(module, bg ? IDS_NEW_SUBVOL_HELP_TEXT : IDS_CREATE_SNAPSHOT_HELP_TEXT, (LPWSTR)pszName, cchMax))
                return S_OK;
            else
                return E_FAIL;
            
        case GCS_VALIDATEA:
        case GCS_VALIDATEW:
            return S_OK;
            
        case GCS_VERBA:
            return StringCchCopyA(pszName, cchMax, bg ? NEW_SUBVOL_VERBA : SNAPSHOT_VERBA);
            
        case GCS_VERBW:
            return StringCchCopyW((STRSAFE_LPWSTR)pszName, cchMax, bg ? NEW_SUBVOL_VERBW : SNAPSHOT_VERBW);
            
        default:
            return E_INVALIDARG;
    }
}
开发者ID:reactos,项目名称:reactos,代码行数:34,代码来源:contextmenu.cpp

示例13: DraughtItemAdding

/*!
	AAテキストを確保して取り込む
	@param[in]	hWnd	ウインドウハンドル
	@param[in]	pcArts	AAテキストSJIS
	@return		追加後のアイテム総数
*/
UINT DraughtItemAdding( HWND hWnd, LPSTR pcArts )
{
	UINT_PTR	cbSize;
	AAMATRIX	stItem;

	INT_PTR	iItems;


	StringCchLengthA( pcArts, STRSAFE_MAX_CCH, &cbSize );

	stItem.cbItem = cbSize;
	stItem.pcItem = (LPSTR)malloc( (cbSize + 1) );
	ZeroMemory( stItem.pcItem, (cbSize + 1) );
	StringCchCopyA( stItem.pcItem, (cbSize + 1), pcArts );


	DraughtAaImageing( hWnd, &stItem );


	gvcDrtItems.push_back( stItem );

	do	//	はみだしてたら?
	{
		iItems = gvcDrtItems.size( );
		if( (TPNL_HORIZ * TPNL_VERTI) < iItems ){	DraughtItemDelete(  0 );	}

	}while( (TPNL_HORIZ * TPNL_VERTI) < iItems );

	return iItems;
}
开发者ID:16in,项目名称:OrinrinEditor,代码行数:36,代码来源:DraughtBoard.cpp

示例14: DsWrapTypedData

_Check_return_ HRESULT
DsWrapTypedData(
	_In_ DbgScriptHostContext* hostCtxt,
	_In_z_ const char* name,
	_In_ const DEBUG_TYPED_DATA* typedData,
	_Out_ DbgScriptTypedObject* typObj)
{
	HRESULT hr = StringCchCopyA(STRING_AND_CCH(typObj->Name), name);
	assert(SUCCEEDED(hr));

	typObj->TypedData = *typedData;
	typObj->TypedDataValid = true;

	hr = fillTypeAndModuleName(
		hostCtxt,
		typObj->TypedData.TypeId,
		typObj->TypedData.ModBase,
		typObj);
	if (FAILED(hr))
	{
		goto exit;
	}
exit:
	return hr;
}
开发者ID:alexbudmsft,项目名称:dbgscript,代码行数:25,代码来源:dstypedobject.cpp

示例15: 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;
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:dprobe,代码行数:60,代码来源:dbgflt.c


注:本文中的StringCchCopyA函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。