本文整理汇总了C++中LPSTR函数的典型用法代码示例。如果您正苦于以下问题:C++ LPSTR函数的具体用法?C++ LPSTR怎么用?C++ LPSTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LPSTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setxp
void setxp()
{
int a = ipa, b = ipb;
char cmd[ 1024 ];
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
sprintf( cmd, "netsh interface ip set address \"區域連線\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254 1", a, b, a );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
sprintf( cmd, "netsh interface ip set dns \"區域連線\" static 140.119.1.110" );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
sprintf( cmd, "netsh interface ip add dns \"區域連線\" 140.119.252.12" );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
示例2: ipcPrepareRequests
void ipcPrepareRequests(int ipcPacketSize, THeaderIPC *pipch, DWORD fRequests)
{
// some fields may already have values like the event object name to open
pipch->cbSize = sizeof(THeaderIPC);
pipch->dwVersion = PLUGIN_MAKE_VERSION(2, 0, 1, 2);
pipch->dwFlags = 0;
pipch->pServerBaseAddress = NULL;
pipch->pClientBaseAddress = pipch;
pipch->fRequests = fRequests;
pipch->Slots = 0;
pipch->IconsBegin = NULL;
pipch->ContactsBegin = NULL;
pipch->GroupsBegin = NULL;
pipch->NewIconsBegin = NULL;
pipch->DataSize = ipcPacketSize - pipch->cbSize;
// the server side will adjust these pointers as soon as it opens
// the mapped file to it's base address, these are set 'ere because ipcAlloc()
// maybe used on the client side and are translated by the server side.
// ipcAlloc() is used on the client side when transferring filenames
// to the ST thread.
pipch->DataPtr = (TSlotIPC*)(LPSTR(pipch) + sizeof(THeaderIPC));
pipch->DataPtrEnd = (TSlotIPC*)(LPSTR(pipch->DataPtr) + pipch->DataSize);
pipch->DataFramePtr = pipch->DataPtr;
// fill the data area
memset(pipch->DataPtr,0 , pipch->DataSize);
}
示例3: set8
void set8()
{
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
int a = ipa, b = ipb;
char cmd[ 1024 ];
sprintf( cmd, "netsh interface ipv4 set address name=\"乙太網路\" source=static address=140.119.%d.%d mask=255.255.255.0 gateway=140.119.%d.254", a, b, a );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.1.110 index=1" );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.252.12 index=2" );
CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
//cleanup
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
示例4: ZeroMemory
void CShortcut::FormatKeyLabel(VirtualKeyName* pVirtualKeyNames,BYTE bKey,BYTE bModifiers,BOOL bScancode,CStringW& str)
{
if (bKey==0)
{
str.LoadString(IDS_SHORTCUTNONE);
return;
}
// Formatting modifiers
if (bModifiers&MOD_WIN)
str.LoadString(IDS_SHORTCUTMODEXT);
else
str.Empty();
if (bModifiers&MOD_CONTROL)
str.AddString(IDS_SHORTCUTMODCTRL);
if (bModifiers&MOD_ALT)
str.AddString(IDS_SHORTCUTMODALT);
if (bModifiers&MOD_SHIFT)
str.AddString(IDS_SHORTCUTMODSHIFT);
if (bScancode)
{
CStringW str2;
str2.Format(IDS_SHORTCUTSCANCODE,(int)bKey);
str << str2;
return;
}
int i;
for (i=0;pVirtualKeyNames[i].bKey!=0 && pVirtualKeyNames[i].bKey!=bKey;i++);
if (pVirtualKeyNames[i].iFriendlyNameId!=0)
{
str.AddString(pVirtualKeyNames[i].iFriendlyNameId);
return;
}
BYTE pKeyState[256];
ZeroMemory(pKeyState,256);
WORD wChar;
int nRet=ToAscii(bKey,0,pKeyState,&wChar,0);
if (nRet==1)
{
MakeUpper((LPSTR)&wChar,1);
str << char(wChar);
}
else if (nRet==2)
{
MakeUpper((LPSTR)&wChar,2);
str << (LPSTR(&wChar))[0] << (LPSTR(&wChar))[0];
}
else if (pVirtualKeyNames[i].pName!=NULL)
str << pVirtualKeyNames[i].pName;
else
str << (int) bKey;
}
示例5: DecideMenuItemInfo
void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnumData *lParam)
{
mii.wID = lParam->idCmdFirst;
lParam->idCmdFirst++;
// get the heap object
HANDLE hDllHeap = lParam->Self->hDllHeap;
TMenuDrawInfo *psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo));
if (pct != NULL) {
psd->cch = pct->cbStrSection - 1; // no null;
psd->szText = (char*)HeapAlloc(hDllHeap, 0, pct->cbStrSection);
lstrcpyA(psd->szText, (char*)pct + sizeof(TSlotIPC));
psd->hContact = pct->hContact;
psd->fTypes = dtContact;
// find the protocol icon array to use && which status
UINT c = lParam->Self->ProtoIconsCount;
TSlotProtoIcons *pp = lParam->Self->ProtoIcons;
psd->hStatusIcon = 0;
while (c > 0) {
c--;
if (pp[c].hProto == pct->hProto && pp[c].pid == lParam->pid) {
psd->hStatusIcon = pp[c].hIcons[pct->Status - ID_STATUS_OFFLINE];
psd->hStatusBitmap = pp[c].hBitmaps[pct->Status - ID_STATUS_OFFLINE];
break;
}
} // while
psd->pid = lParam->pid;
}
else if (pg != NULL) {
// store the given ID
pg->hMenuGroupID = mii.wID;
// steal the pointer from the group node it should be on the heap
psd->cch = pg->cchGroup;
psd->szText = pg->szGroup;
psd->fTypes = dtGroup;
} // if
psd->wID = mii.wID;
psd->szProfile = NULL;
// store
mii.dwItemData = UINT_PTR(psd);
if (lParam->bOwnerDrawSupported && lParam->bShouldOwnerDraw) {
mii.fType = MFT_OWNERDRAW;
mii.dwTypeData = (LPSTR)psd;
}
else {
// normal menu
mii.fType = MFT_STRING;
if (pct != NULL)
mii.dwTypeData = LPSTR(pct) + sizeof(TSlotIPC);
else
mii.dwTypeData = pg->szGroup;
// For Vista + let the system draw the theme && icons, pct = contact associated data
if (bIsVistaPlus && pct != NULL && psd != NULL) {
mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID | MIIM_DATA | MIIM_STRING;
// BuildSkinIcons() built an array of bitmaps which we can use here
mii.hbmpItem = psd->hStatusBitmap;
}
}
}
示例6: GetSocket
BOOL CXMMTCtrl::PostMmttyMessageAsString(short nIndex, long wParam, LPCTSTR pStr)
{
int r = FALSE;
CCSocket *pSocket = GetSocket(nIndex);
if( pSocket ){
int len = sizeof(COMMSG) + lstrlen(pStr) + 1;
LPBYTE pb = new BYTE[len];
COMMSG *pCom = (COMMSG *)pb;
pCom->m_wParam = wParam;
pCom->m_lParam = 0;
// 文字列の実体をCOMMSGのすぐ後ろにコピーします。
#ifdef _UNICODE
LPSTR p = LPSTR(pb + sizeof(COMMSG));
while(*pStr){
*p++ = BYTE(*pStr++);
}
*p = 0;
#else
lstrcpy(LPTSTR(pb + sizeof(COMMSG)), pStr);
#endif
CCustomSession cs(COM_MESSAGE, pb, len);
delete pb;
int size;
CUSTOMHEAD *pHeader = cs.GetHeader(size);
r = SendBuf(pSocket, pHeader, size);
}
return r;
}
示例7: Dlg_Warning
static BOOL CALLBACK Dlg_Warning(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
CenterDlg(hDlg, -80); //Центрирование окна диалога в главном окне
SetWindowText(hDlg, (Lan+36)->msg); //Вывели новый заголовок
OutNameDlg(hDlg, IDC_STATICTEXT1, LPSTR(lParam)); //Усечение имени файла
SetDlgItemText(hDlg, IDC_STATICTEXT2, (Lan+65)->msg);
SetDlgItemText(hDlg, IDC_REWRITE, (Lan+66)->msg);
SetDlgItemText(hDlg, IDC_NEW, (Lan+67)->msg);
SetDlgItemText(hDlg, IDCANCEL, (Lan+68)->msg);
return TRUE;
case WM_CTLCOLORSTATIC:
if(GetDlgCtrlID(HWND(lParam)) == IDC_STATICTEXT2)
{ SetTextColor((HDC)wParam, RGB(255, 0, 0));
SetBkColor((HDC)wParam, FonLTGRAY);
return (BOOL)FonBrush;
}
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{ case IDC_REWRITE:
case IDC_NEW:
case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); //Вернули один из трех кодов
return TRUE;
}
break;
}
return FALSE;
}
示例8: ID_Motion
MotionID CKinematicsAnimated::ID_Motion(LPCSTR N, u16 slot)
{
MotionID motion_ID;
if (slot<MAX_ANIM_SLOT){
shared_motions* s_mots = &m_Motions[slot].motions;
// find in cycles
accel_map::iterator I = s_mots->cycle()->find(LPSTR(N));
if (I!=s_mots->cycle()->end()) motion_ID.set(slot,I->second);
if (!motion_ID.valid()){
// find in fx's
accel_map::iterator I = s_mots->fx()->find(LPSTR(N));
if (I!=s_mots->fx()->end()) motion_ID.set(slot,I->second);
}
}
return motion_ID;
}
示例9: memset
/*********************************************************************
* 函数名称:int Write_Log_Text(LPLOG_DATA lpLogData)
* 说明:写日志内容
* 调用者:Write_Log
* 输入参数:
* LPLOG_DATA lpLogData --日志内容结构体量
* 输出参数:
* 无
* 返回值:
* int -- LOG_FAILED: 失败
* -- LOG_SUCCESS: 成功
*********************************************************************/
int CWriteLog::Write_Log_Text(LPLOG_DATA lpLogData)
{
TCHAR szFilePath[MAX_FILE_PATH];
TCHAR szFileName[MAX_LOG_FILE_NAME_LEN];
FILE *pFile = NULL;
TCHAR szLogText[MAX_LOGTEXT_LEN];
memset(szFilePath, 0, MAX_FILE_PATH);
memset(szFileName, 0, MAX_LOG_FILE_NAME_LEN);
memset(szLogText, 0, MAX_LOGTEXT_LEN);
GetLogPath(szFilePath);
GetLogFileName(lpLogData->iType, szFilePath, szFileName);
pFile = _tfopen(szFileName, _T("a+"));
if(NULL == pFile)
{
return LOG_FAILED;
}
_stprintf(szLogText, _T("%s[%s %s] %s ----- [%s][%d]\n"), lpLogData->strModel, lpLogData->strDate, lpLogData->strTime, lpLogData->strText, lpLogData->strFile, lpLogData->iLine);
//fwrite(szLogText, 1, _tcslen(szLogText), pFile);
//acsii 的方式, unicode写入乱码
int len = _tcslen(szLogText);
char* pchBuffer = new char[len * 2 + 1];
int a = WideCharToMultiByte(CP_ACP, NULL, (LPCWCH)szLogText, -1, LPSTR(pchBuffer), len*2 + 1, NULL, FALSE);//Unicode转换为ANSI,a的值包括了字符串最后的0
fwrite(pchBuffer, 1, a - 1, pFile);
delete[] pchBuffer;
pchBuffer = NULL;
fclose(pFile);
return LOG_SUCCESS;
}
示例10: LPSTR
/**
* @brief Convert a Windows style path to a file name into an Unix style one.
*
* @param filename pointer to the file path to be converted
*
* @return pointer to the converted file path
*/
static char *unix_name (char *filename)
{
static char *unix_filename;
LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR);
int wchar_conv;
if (*filename && (filename[1] == ':'))
{
wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name");
wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);
if (wine_get_unix_file_name_ptr && wchar_conv)
{
WCHAR *ntpath;
char *unix_name;
ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1));
MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv);
unix_name = wine_get_unix_file_name_ptr(ntpath);
setdup(&unix_filename, unix_name);
filename = unix_filename;
HeapFree(GetProcessHeap(), 0, unix_name);
HeapFree(GetProcessHeap(), 0, ntpath);
}
}
return filename;
}
示例11: clear
void TextIndex::make_index(LPCSTR sourceTxt)
{
clear();
strcpy_s(fileName, 256, sourceTxt);
if(!strchr(fileName, '.')){
strcat_s(fileName, 256, ".txt"); // append extension if missing
}
Filemap txtFileMap;
LPVOID txtAddrBase = txtFileMap.open_read(fileName, FALSE);
if(txtAddrBase){
LPVOID seekAddr = txtAddrBase;
LPVOID eofAddr = LPVOID(DWORD(txtAddrBase) + txtFileMap.getSize());
Heap::init(0x8000); // maximum amount of memory per section index
while(seekAddr < eofAddr){
LPVOID foundAddr = memchr(seekAddr, '\n', DWORD(eofAddr) - DWORD(seekAddr));
if(!foundAddr){
break; // invalid file, no newlines
}
char parseBuffer[512]; // maximum line length
memcpy_s(parseBuffer, 512, seekAddr, DWORD(foundAddr) - DWORD(seekAddr) + 1);
kill_newline(parseBuffer);
trim_spaces(parseBuffer);
if(parseBuffer[0] == '#' && isupper(parseBuffer[1])){
DWORD len = strlen(&parseBuffer[1]) + 1;
LPVOID storeAddr = Heap::get(len + 4); // section name + address
*(LPDWORD)storeAddr = DWORD(seekAddr) - DWORD(txtAddrBase); // file offset
strcpy_s(LPSTR(storeAddr) + 4, len, &parseBuffer[1]);
sectionCount++;
}
seekAddr = LPVOID(DWORD(foundAddr) + 1);
}
Heap::squeeze();
}
}
示例12: while
//选出一个权重,次数,分类,特征
map <string, map<string, Feature>> Model::getallfeature()
{
auto cats=this->catcounts();
auto itcat = cats.begin();
map <string, map<string, Feature>> result;
while (itcat != cats.end())
{
string query = "select feature,weight,count from nfc where cat='"+itcat->first+"'";
m_pRecordset = this->GetRecordSet(query.c_str());
map<string, Feature> tempacat;
while (!m_pRecordset->adoEOF)
{
Feature fea;
string feature = LPSTR(_bstr_t(m_pRecordset->GetCollect("feature")));
double weight = m_pRecordset->GetCollect("weight");
int count = m_pRecordset->GetCollect("count");
fea.weight = weight;
fea.count = count;
tempacat.insert(make_pair(feature, fea));
m_pRecordset->MoveNext();
}
result.insert(make_pair(itcat->first,tempacat));
++itcat;
}
return result;
}
示例13: ShowOpenFileDialog
bool ShowOpenFileDialog(char* FileName, int FileNameLength, char* filter)
// Open a dialog for selecting a file and returns true if succeeded with the name of the file in the preallocated buffer <FileName>
{
OPENFILENAMEA ofn ;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrDefExt = 0;
FileName[0] = '\0';
ofn.lpstrFile = FileName;
ofn.nMaxFile = FileNameLength;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
char strAux[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, strAux);
ofn.lpstrInitialDir = strAux;
ofn.lpstrTitle = LPSTR("Open File");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ENABLESIZING;
GetOpenFileNameA(&ofn);
if (strlen(ofn.lpstrFile) == 0) return false;
return true;
} // ShowOpenFileDialog
示例14: memcpy
BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen)
{
if (cbResultLen)
*cbResultLen = 0;
if (!m_valid || src == NULL || cbLen >= 0xFFFE)
return NULL;
BYTE *tmpBuf = (BYTE*)_alloca(cbLen + 2);
*(PWORD)tmpBuf = (WORD)cbLen;
memcpy(tmpBuf + 2, src, cbLen);
cbLen += 2;
size_t rest = cbLen % BLOCK_SIZE;
if (rest)
cbLen += BLOCK_SIZE - rest;
BYTE *result = (BYTE*)mir_alloc(cbLen);
m_aes.ResetChain();
if (m_aes.Encrypt(tmpBuf, LPSTR(result), cbLen)) {
mir_free(result);
return NULL;
}
if (cbResultLen)
*cbResultLen = cbLen;
return result;
}
示例15: LPSTR
bool NetChannel::AsynRecv(PBYTE pData, long lDataSize)
{
if( pData == NULL || lDataSize <= 0)
return false;
MYOVERLAPPED& olp = m_OLPRecv;
WSABUF wsabuf;
wsabuf.buf = LPSTR( pData );
wsabuf.len = lDataSize;
DWORD dwTransed = 0;
DWORD dwFlags = 0;
if ( WSARecv( m_socket.GetSocket(), &wsabuf, 1, &dwTransed, &dwFlags, (LPWSAOVERLAPPED)&olp, NULL ) != 0)
{
int32 nError = WSAGetLastError();
if( nError != WSA_IO_PENDING )
{
OnExitReceiving();
return false;
}
}
m_pMgr->BytesRecv().Add(lDataSize);
return true;
}