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


C++ StringCbCopy函数代码示例

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


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

示例1: GetLanguageResource

HMODULE GetLanguageResource()
{
	HKEY hKey;
	LPSTR lanFile=NULL;
	if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Update\\Locate32",0,KEY_READ,&hKey)==ERROR_SUCCESS)
	{
		DWORD lLength;
		if (RegQueryValueEx(hKey,"Language",0,NULL,NULL,&lLength)==ERROR_SUCCESS)
		{
			lanFile=new char[lLength+1];
			if (RegQueryValueEx(hKey,"Language",0,NULL,(LPBYTE)lanFile,&lLength)!=ERROR_SUCCESS)
			{
				delete[] lanFile;
				lanFile=NULL;
			}
		}
		RegCloseKey(hKey);
	}


	char szPath[MAX_PATH];
	int nLen=GetModuleFileName(g_hmodThisDll,szPath,MAX_PATH);
	for (nLen--;nLen>=0 && szPath[nLen]!='\\';nLen--);
	nLen++;
    
	if (lanFile==NULL)
		StringCbCopy(szPath+nLen,MAX_PATH-nLen,"lan_en.dll");
	else
	{
        StringCbCopy(szPath+nLen,MAX_PATH-nLen,lanFile);
		delete[] lanFile;
	}

	return LoadLibrary(szPath);
}
开发者ID:joshball,项目名称:locate32-cogit.net,代码行数:35,代码来源:CtxMenu.Cpp

示例2: CreateSave

SAVESTATE_t* CreateSave(const TCHAR *author, const TCHAR *comment , int model) {
	SAVESTATE_t* save = (SAVESTATE_t*) malloc(sizeof(SAVESTATE_t));
	if (!save) return NULL;

	save->version_major = CUR_MAJOR;
	save->version_minor = CUR_MINOR;
	save->version_build = CUR_BUILD;

	memset(save->author, 0, sizeof(save->author));
	memset(save->comment, 0, sizeof(save->comment));
#ifdef WINVER
#ifdef _UNICODE
	char buffer[64];
	size_t numConv;
	wcstombs_s(&numConv, save->author, author, sizeof(save->author));
	wcstombs_s(&numConv, save->comment, comment, sizeof(save->author));
#else
	StringCbCopy(save->author, sizeof(save->author), author);
	StringCbCopy(save->comment, sizeof(save->comment), comment);
#endif
#else
	strncpy(save->author, author, sizeof(save->author));
	strncpy(save->comment, comment, sizeof(save->comment));
#endif
	
	save->model = model;
	save->chunk_count = 0;
	
	u_int i;
	for(i = 0; i < NumElm(save->chunks); i++) {
		save->chunks[i] = NULL;
	}
	return save;
}
开发者ID:DragonNeos,项目名称:wabbitemu-psp,代码行数:34,代码来源:savestate.c

示例3: ProfileStringIn

/******************************Public*Routine******************************\
* ProfileStringIn
*
\**************************************************************************/
UINT
ProfileStringIn(
    LPTSTR  szKey,
    LPTSTR  szDefault,
    LPTSTR  szProfileString,
    DWORD   cb
    )
{
    CheckPointer(szKey,0);
    CheckPointer(szDefault,0);
    CheckPointer(szProfileString,0);

    HKEY  hKey;
    DWORD dwType;

    if((hKey = GetAppKey(FALSE)) == 0)
    {
        StringCbCopy(szProfileString, cb, szDefault);
        return lstrlen(szProfileString);
    }

    if((RegQueryValueEx(hKey, szKey, NULL, &dwType, 
                       (LPBYTE)szProfileString, &cb) != ERROR_SUCCESS)
        || dwType != REG_SZ)
    {
        StringCbCopy(szProfileString, cb, szDefault);
        cb = lstrlen(szProfileString);
    }

    RegCloseKey(hKey);
    return cb;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:36,代码来源:persist.cpp

示例4: DropExt_GetNetResource

//
// This is a helper routine which extracts a specified NETRESOURCE from hnres.
//
UINT DropExt_GetNetResource(HGLOBAL hnres, UINT iItem, LPNETRESOURCE pnresOut, UINT cbMax)
{
    LPNRESARRAY panr = GlobalLock(hnres);
    UINT iRet = 0;	// assume error
    if (hnres)
    {
	if (iItem==(UINT)-1)
	{
	    iRet = panr->cItems;
	}
	else if (iItem < panr->cItems)
	{
	    UINT cbProvider, cbRemoteName;
	    LPCSTR pszProvider = _Offset2Ptr((LPSTR)panr, (UINT_PTR)panr->nr[iItem].lpProvider, &cbProvider);
	    LPCSTR pszRemoteName = _Offset2Ptr((LPSTR)panr, (UINT_PTR)panr->nr[iItem].lpRemoteName, &cbRemoteName);
	    iRet = sizeof(NETRESOURCE) + cbProvider + cbRemoteName;
	    if (iRet <= cbMax)
	    {
		LPSTR psz = (LPSTR)(pnresOut+1);
		*pnresOut = panr->nr[iItem];
		if (pnresOut->lpProvider) {
		    pnresOut->lpProvider = psz;
		    StringCbCopy(psz, cbProvider, pszProvider);
		    psz += cbProvider;
		}
		if (pnresOut->lpRemoteName) {
		    pnresOut->lpRemoteName = psz;
		    StringCbCopy(psz, cbRemoteName, pszRemoteName);
		}
	    }
	}
	GlobalUnlock(hnres);
    }
    return iRet;
}
开发者ID:SatishSara,项目名称:zxlooong,代码行数:38,代码来源:DropExt.C

示例5: CBaseContent

CTask::CTask(CONTENT_ID id, LPWSTR name, LPWSTR details, LPWSTR category, LPWSTR dueTime) :
    CBaseContent()
{
    HRESULT hr = E_FAIL;
    m_contentID = id;

    hr = StringCbCopy(m_wszName, sizeof(m_wszName), name);
    if (FAILED(hr))
    {
        //handle the error
    }

    hr = StringCbCopy(m_wszDetails, sizeof(m_wszDetails), details);
    if (FAILED(hr))
    {
        //handle the error
    }

    hr = StringCbCopy(m_wszCategory, sizeof(m_wszCategory), category);
    if (FAILED(hr))
    {
        //handle the error
    }

    hr = StringCbCopy(m_wszTimeDue, sizeof(m_wszTimeDue), dueTime);
    if (FAILED(hr))
    {
        //handle the error
    }

    m_prevId = id-1;
    m_nextId = id+1;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:33,代码来源:Task.cpp

示例6: nt_set_env

void nt_set_env(const Char *name, const Char *val) {
	char *cname, *cval;
	int len;

	cname = name?short2str(name):NULL;
	if(cname) {
		len = lstrlen(cname);
		nameBuf = heap_alloc(len+1);
		if (!nameBuf) {
			stderror(ERR_TOOLARGE);
		}
		StringCbCopy(nameBuf,len+1,cname);
	}
	cval = val?short2str(val):NULL;
	if(cval) {
		len = lstrlen(cval);
		valBuf = heap_alloc(len+1);
		StringCbCopy(valBuf,len+1,cval);
	}

	SetEnvironmentVariable(nameBuf,cval?valBuf:NULL);

	if (!lstrcmp(nameBuf,"TCSHONLYSTARTEXES")) 
		init_shell_dll();

	heap_free(nameBuf);
	if (cval)
		heap_free(valBuf);


}
开发者ID:phase,项目名称:tcsh,代码行数:31,代码来源:ntfunc.c

示例7: perf_set_thread_desc

KHMEXP void
perf_set_thread_desc(const char * file, int line,
                     const wchar_t * name, const wchar_t * creator) {
    thread_info * t;
    char * fn_copy;

    perf_once();

    t = malloc(sizeof(*t));
    ZeroMemory(t, sizeof(*t));

#ifdef _WIN32
    t->thread = GetCurrentThreadId();
#else
#error Unsupported platform
#endif

    StringCbCopy(t->name, sizeof(t->name), name);
    if (creator)
        StringCbCopy(t->creator, sizeof(t->creator), creator);

    if (file[0] == '.' && file[1] == '\\')
        file += 2;

    EnterCriticalSection(&cs_alloc);

    fn_copy = hash_lookup(&fn_hash, file);
    if (fn_copy == NULL) {
        size_t cblen = 0;
        if (FAILED(StringCbLengthA(file, MAX_PATH * sizeof(char),
                                   &cblen)))
            fn_copy = NULL;
        else {
            fn_copy = malloc(cblen + sizeof(char));
            if (fn_copy) {
                hash_bin * b;
                int hv;

                StringCbCopyA(fn_copy, cblen + sizeof(char), file);

                hv = fn_hash.hash(fn_copy) % fn_hash.n;

                b = malloc(sizeof(*b));
                b->data = fn_copy;
                b->key = fn_copy;
                LINIT(b);
                LPUSH(&fn_hash.bins[hv], b);
            }
        }
    }

    t->file = fn_copy;
    t->line = line;

    LPUSH(&threads, t);
    LeaveCriticalSection(&cs_alloc);
}
开发者ID:aosm,项目名称:Kerberos,代码行数:57,代码来源:perfstat.c

示例8: afs_method_describe

khm_boolean
afs_method_describe(afs_tk_method method, khm_int32 flags,
                    wchar_t * wbuf, khm_size cbbuf) {
    khm_size idx;

    switch(method) {
    case AFS_TOKEN_AUTO:
        return LoadString(hResModule,
                          ((flags & KCDB_TS_SHORT)? 
                           IDS_NC_METHOD_AUTO:
                           IDS_NC_METHODL_AUTO),
                          wbuf, (int) cbbuf / sizeof(wchar_t));

    case AFS_TOKEN_KRB5:
        return LoadString(hResModule,
                          ((flags & KCDB_TS_SHORT)?
                           IDS_NC_METHOD_KRB5:
                           IDS_NC_METHODL_KRB5),
                          wbuf, (int) cbbuf / sizeof(wchar_t));

    case AFS_TOKEN_KRB524:
        return LoadString(hResModule,
                          ((flags & KCDB_TS_SHORT)?
                           IDS_NC_METHOD_KRB524:
                           IDS_NC_METHODL_KRB524),
                          wbuf, (int) cbbuf / sizeof(wchar_t));

    case AFS_TOKEN_KRB4:
        return LoadString(hResModule,
                          ((flags & KCDB_TS_SHORT)?
                           IDS_NC_METHOD_KRB4:
                           IDS_NC_METHODL_KRB4),
                          wbuf, (int) cbbuf / sizeof(wchar_t));

    default:
        for (idx = 0; idx < n_extensions; idx++) {
            if(!extensions[idx].provide_token_acq ||
               extensions[idx].token_acq.method_id != method)
                continue;

            if ((flags & KCDB_TS_SHORT) ||
                extensions[idx].token_acq.long_desc == NULL)
                return SUCCEEDED(StringCbCopy(wbuf, cbbuf,
                                              extensions[idx].token_acq.short_desc));
            else
                return SUCCEEDED(StringCbCopy(wbuf, cbbuf,
                                              extensions[idx].token_acq.long_desc));
        }
    }

    return FALSE;
}
开发者ID:snktagarwal,项目名称:openafs,代码行数:52,代码来源:afsext.c

示例9: k5_add_file_cc

void k5_add_file_cc(k5_ccc_data * d, wchar_t * epath) {
    khm_size i;
    khm_size cch;
    wchar_t path[MAX_PATH];

    if (FAILED(StringCchLength(epath, MAX_PATH, &cch)) ||
        cch == 0)
        return;

    StringCbCopy(path, sizeof(path), epath);
    unexpand_env_var_prefix(path, sizeof(path));

    /* see if it's there first */
    for (i=0; i < d->n_file_ccs; i++) {
        if(!_wcsicmp(d->file_ccs[i].path, path))
            return;
    }

    if (d->n_file_ccs == d->nc_file_ccs) {
        k5_file_cc * f;

        d->nc_file_ccs = UBOUNDSS(d->n_file_ccs + 1,
                                  K5_FCC_ALLOC_INCR,
                                  K5_FCC_ALLOC_INCR);
#ifdef DEBUG
        assert(d->nc_file_ccs > d->n_file_ccs);
#endif
        f = PMALLOC(sizeof(*f) * d->nc_file_ccs);
        ZeroMemory(f, sizeof(*f) * d->nc_file_ccs);

        if (d->n_file_ccs > 0) {
#ifdef DEBUG
            assert(d->file_ccs != NULL);
#endif
            memcpy(f, d->file_ccs, sizeof(*f) * d->n_file_ccs);
        }
        if (d->file_ccs)
            PFREE(d->file_ccs);
        d->file_ccs = f;
    }

    StringCbCopy(d->file_ccs[d->n_file_ccs].path,
                 sizeof(d->file_ccs[0].path),
                 path);
    if(PathFileExists(path))
        d->file_ccs[d->n_file_ccs].flags = K5_FCC_FLAG_EXISTS;
    else
        d->file_ccs[d->n_file_ccs].flags = 0;

    d->n_file_ccs++;
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:51,代码来源:krb5configcc.c

示例10: kmmint_get_plugin_i

kmm_plugin_i *
kmmint_get_plugin_i(wchar_t * name)
{
    kmm_plugin_i * p;
    size_t cb;

    if(FAILED(StringCbLength(name, KMM_MAXCB_NAME, &cb)))
        return NULL;
    cb += sizeof(wchar_t);

    EnterCriticalSection(&cs_kmm);
    p = (kmm_plugin_i *) hash_lookup(hash_plugins, (void *) name);

    if(p == NULL) {
        p = PMALLOC(sizeof(kmm_plugin_i));
        ZeroMemory(p, sizeof(kmm_plugin_i));
        p->magic = KMM_PLUGIN_MAGIC;
        p->p.name = PMALLOC(cb);
        StringCbCopy(p->p.name, cb, name);
        p->state = KMM_PLUGIN_STATE_NONE;

        hash_add(hash_plugins, (void *) p->p.name, (void *) p);
        kmmint_list_plugin(p);
    }
    LeaveCriticalSection(&cs_kmm);

    return p;
}
开发者ID:Brainiarc7,项目名称:pbis,代码行数:28,代码来源:kmm_plugin.c

示例11: Insert

//꼬리에 삽입
DWORD Insert(LISTMGR* pListMgr, PROCESS_INFO* pData)
{
	LLIST *pNewList;

	pNewList = (LLIST*)HeapAlloc(GetProcessHeap(), HEAP_NO_SERIALIZE, sizeof(LLIST));
	pNewList->data.Depth = pData->Depth;
	pNewList->data.Pid = pData->Pid;
	pNewList->data.ParentId = pData->ParentId;
	StringCbCopy(pNewList->data.pszProcessName, 128, pData->pszProcessName);
	pNewList->pNext = NULL;

	if (pListMgr->NumOfContents == 0)
	{
		pListMgr->pHead = pNewList;
		pListMgr->pCur = pNewList;
		pListMgr->pTail = pNewList;
	}
	else
	{
		pListMgr->pTail->pNext = pNewList;
		pListMgr->pTail = pNewList;
	}

	return ++pListMgr->NumOfContents;
}
开发者ID:gkscndrl,项目名称:GoldRushData,代码行数:26,代码来源:list.c

示例12: kcdb_type_get_name

KHMEXP khm_int32 KHMAPI kcdb_type_get_name(khm_int32 id, wchar_t * buffer, khm_size * cbbuf)
{
    size_t cbsize;
    kcdb_type_i * t;

    if(id < 0 || id > KCDB_TYPE_MAX_ID || !cbbuf)
        return KHM_ERROR_INVALID_PARAM;

    t = kcdb_type_tbl[id];

    if(!t)
        return KHM_ERROR_NOT_FOUND;

    if(FAILED(StringCbLength(t->type.name, KCDB_MAXCB_NAME, &cbsize)))
        return KHM_ERROR_UNKNOWN;

    cbsize += sizeof(wchar_t);

    if(!buffer || *cbbuf < cbsize) {
        *cbbuf = cbsize;
        return KHM_ERROR_TOO_LONG;
    }

    StringCbCopy(buffer, *cbbuf, t->type.name);
    *cbbuf = cbsize;

    return KHM_ERROR_SUCCESS;
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:28,代码来源:type.c

示例13: kcdb_type_data_toString

khm_int32 KHMAPI kcdb_type_data_toString(
    const void * d,
    khm_size cbd,
    wchar_t * buffer,
    khm_size * cb_buf,
    khm_int32 flags)
{
    size_t cbsize;

    if(!cb_buf)
        return KHM_ERROR_INVALID_PARAM;

    cbsize = sizeof(GENERIC_DATA_STR);

    if(!buffer || *cb_buf < cbsize) {
        *cb_buf = cbsize;
        return KHM_ERROR_TOO_LONG;
    }

    StringCbCopy(buffer, *cb_buf, GENERIC_DATA_STR);

    *cb_buf = cbsize;

    return KHM_ERROR_SUCCESS;
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:25,代码来源:type.c

示例14: kvno_toString

khm_int32 KHMAPI
kvno_toString(const void * data, khm_size cbdata,
              wchar_t *destbuf, khm_size *pcbdestbuf,
              khm_int32 flags)
{
    int resid = 0;
    int kvno;
    wchar_t buf[256];
    size_t cblength;

    if (cbdata != sizeof(khm_int32))
        return KHM_ERROR_INVALID_PARAM;

    kvno = *((khm_int32 *) data);

    StringCbPrintf(buf, sizeof(buf), L"#%d", kvno);

    StringCbLength(buf, ARRAYLENGTH(buf), &cblength);
    cblength += sizeof(wchar_t);

    if (!destbuf || *pcbdestbuf < cblength) {
        *pcbdestbuf = cblength;
        return KHM_ERROR_TOO_LONG;
    } else {
        StringCbCopy(destbuf, *pcbdestbuf, buf);
        *pcbdestbuf = cblength;
        return KHM_ERROR_SUCCESS;
    }
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:29,代码来源:datarep.c

示例15: LoadStringW

int CWnd::ShowErrorMessage(UINT nIDMsgStr,UINT nIDTitleStr,UINT uType) const
{
	if (IsUnicodeSystem())
	{
		WCHAR title[100];
		WCHAR msg[1000];
		LoadStringW(GetLanguageSpecificResourceHandle(),nIDMsgStr,msg,1000);
		if (nIDTitleStr)
			LoadStringW(GetLanguageSpecificResourceHandle(),nIDTitleStr,title,100);
		else
			StringCbCopyW(title,100*2,szwError);
		return ::MessageBoxW(m_hWnd,msg,title,uType);
	}
	else
	{
		char title[100];
		char msg[1000];
		LoadString(nIDMsgStr,msg,1000);
		if (nIDTitleStr)
			LoadString(nIDTitleStr,title,100);
		else
			StringCbCopy(title,100,szError);
		return ::MessageBox(m_hWnd,msg,title,uType);
	}
}
开发者ID:eladkarako,项目名称:locate32,代码行数:25,代码来源:WindowClasses.cpp


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