日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > > 充電吧
[導(dǎo)讀]……21,程序只允許一個實例運行//在這個位置調(diào)用FirstInstance函數(shù)?BOOL CWindowsApp::InitInstance()?{?if (!FirstInstance())?re

……21,程序只允許一個實例運行
//在這個位置調(diào)用FirstInstance函數(shù)?
BOOL CWindowsApp::InitInstance()?
{?
if (!FirstInstance())?
return FALSE; //已經(jīng)有實例存在了,退出?
AfxEnableControlContainer();?
}?
//FirstInstance函數(shù)?
BOOL FirstInstance()?
{?
CWnd *pWndPrev;?
//根據(jù)主窗口類名和主窗口名判斷是否已經(jīng)有實例存在了?
if (pWndPrev = CWnd::FindWindow("#32770","Windows秘書"))//第二個參數(shù)為程序名?
{
//如果存在就將其激活,并顯示出來?
pWndPrev->ShowWindow(SW_RESTORE);?
pWndPrev->SetForegroundWindow();?
return FALSE;?
}else{
return TRUE;?
}?
}

………22,取得系統(tǒng)時間及計算時間差
DWORD system_runtime;?
system_runtime=GetTickCount()/60000;//取得系統(tǒng)運行時間?
SYSTEMTIME sysTime; // Win32 time information?
GetLocalTime(&sysTime);?
COleDateTime now(sysTime);?
//COleDateTime now;?
//now=now.GetCurrentTime();?
//GetCurrentTime()取得時間與time( time_t *timer );和struct tm *localtime( const time_t *timer );所得時間相同只能到2037年?
//而GetLocalTime(&sysTime);可到9999年?
m_zbyear=now.GetYear();//年?
m_zbmonth=now.GetMonth();//月?
m_zbday=now.GetDay();//日?
now.GetDayOfWeek();//weekday?
COleDateTimeSpan sub;?
sub.SetDateTimeSpan(m_howdaysafteris,0,0,0);//設(shè)定時間差為天數(shù)?
now+=sub;?
then.SetDateTime(,,,,,,,);//其它方式添加時保存的當(dāng)時時間?
if(!now.SetDate(m_jsyear,m_jsmonth,m_jsday)//檢查時間是否正確 &&!then.SetDate(m_jsyear2,m_jsmonth2,m_jsday2))?
{?
sub=then-now;?
CString cs;?
cs.Format("%d年%d月%d日 相距 %d年%d月%d日/n/n %.0f天",m_jsyear,m_jsmonth,m_jsday,?
m_jsyear2,m_jsmonth2,m_jsday2,sub.GetTotalDays());?
MessageBox(cs);?
}?
else?
MessageBox("您輸入的時間有誤,請重新輸入!","Windows秘書",MB_OK|MB_ICONSTOP);?

………23,文件操作
//打開文件對話框?
CFileDialog dlg(TRUE, "mp3", NULL, OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR,?
"音樂/電影文件(*.mp3,*.wav,*.avi,*.asf)|*.mp3;*.wav;*.avi;*.asf|"/?
"mp3 文件(*.mp3)|*.mp3|" /?
"音頻文件 (*.wav)|*.wav|" /?
"視頻文件 (*.avi)|*.avi|" /?
"Window Media 文件(*.asf)|*.asf|" /?
"所有文件 (*.*)|*.*||");?
if(dlg.DoModal()==IDOK)?
{?
CString m_filename=dlg.GetPathName();?
}?
//讀取文件?
CFile file;?
If (file.Open(m_filename,CFile::modeRead))?
{?
file.Read(zbpassword,sizeof(zbpassword));?
}?
file.Close();?
//寫入文件?
if (file.Open(m_zbfilename,CFile::modeCreate|CFile::modeWrite))?
{?
zbfile.Write(zbpassword,sizeof(zbpassword));?
}?
file.Close();?

………24,進制轉(zhuǎn)換
CString BinaryToDecimal(CString strBinary)//轉(zhuǎn)換二進制為十進制?
{?
int nLenth = strBinary.GetLength();?
char* Binary = new char[nLenth];?
Binary = strBinary.GetBuffer(0);?
int nDecimal = 0;?
for(int i=0;i<nLenth;i++)?
{?
char h = Binary[nLenth-1-i];?
char str[1];?
str[0] = h;?
int j = atoi(str);?
for(int k=0;k<i;k++) j=j*2;??
nDecimal += j;?
}?
CString strDecimal;?
strDecimal.Format("%d",nDecimal);?
return strDecimal;?
}?
CString BinaryToHex(CString strBinary)//轉(zhuǎn)換二進制為十六進制?
{?
int nLength = strBinary.GetLength();?
CString str = strBinary;?
//位數(shù)不是四的倍數(shù)時補齊?
switch(nLength%4)?
{?
case 0:?
break;?
case 1:?
strBinary.Format("%d%d%d%s",0,0,0,str);?
break;?
case 2:?
strBinary.Format("%d%d%s",0,0,str);?
break;?
case 3:?
strBinary.Format("%d%s",0,str);?
break;?
default:?
return "";?
break;?
}?
CString strHex,str1;?
str1 = "";?
nLength = strBinary.GetLength();?
for(int i=1;i<=(nLength/4);i++)?
{?
//每四位二進制數(shù)轉(zhuǎn)換為一十六進制數(shù)?
str = strBinary.Left(4);?
CString strDecimal = BinaryToDecimal(str);?
int nDecimal = atoi(strDecimal.GetBuffer(0));?
if (nDecimal<10)?
str1.Format("%d",nDecimal);?
else?
{?
char c = 'A' + (nDecimal-10);?
str1.Format("%c",c);?
}?
strHex += str1;?
strBinary = strBinary.Right(strBinary.GetLength()-str.GetLength());?
}?
return strHex;?
}?
unsigned char BtoH(char ch)//將16進制的一個字符轉(zhuǎn)換為十進制的數(shù)?
{?
//0-9?
if (ch >= '0' && ch <= '9')?
return (ch - '0');?
//9-15?
if (ch >= 'A' && ch <= 'F')?
return (ch - 'A' + 0xA);?
//9-15?
if (ch >= 'a' && ch <= 'f')?
return (ch - 'a' + 0xA);?
return(255);?
}?
CString DecimalToBinary(CString strDecimal)//轉(zhuǎn)換十進制為二進制?
{?
int nDecimal = atoi(strDecimal.GetBuffer(0));?
int nYushu; //余數(shù)?
int nShang; //商?
CString strBinary = "";?
char buff[2];?
CString str = "";?
BOOL bContinue = TRUE;?
while(bContinue)?
{?
nYushu = nDecimal%2;?
nShang = nDecimal/2;?
sprintf(buff,"%d",nYushu);?
str = strBinary;?
strBinary.Format("%s%s",buff,str);?
nDecimal = nShang;?
if(nShang==0)?
bContinue = FALSE;?
}?
return strBinary;?
}?

CString BinaryToDecimal(CString strBinary)//轉(zhuǎn)換二進制為十進制?
{?
int nLenth = strBinary.GetLength();?
char* Binary = new char[nLenth];?
Binary = strBinary.GetBuffer(0);?
int nDecimal = 0;?
for(int i=0;i<nLenth;i++)?
{?
char h = Binary[nLenth-1-i];?
char str[1];?
str[0] = h;?
int j = atoi(str);?
for(int k=0;k<i;k++) j=j*2;??
nDecimal += j;?
}?
CString strDecimal;?
strDecimal.Format("%d",nDecimal);?
return strDecimal;?
}?

………25,數(shù)學(xué)函數(shù)
sin();?
cos();?
tan();?
sqrt();?
pow(x,y);?
log();?
log10();?

………26,遞歸法遍歷磁盤目錄
void CQt::BrowseDir(CString strDir)?
{?
CFileFind ff;?
CString str,cs,inifile;?
inifile=regfilepath;?
inifile+="http://Windows秘書.ini";?
CString szDir = strDir;?
int index;?
char jjj,ppp,ggg;?
if(szDir.Right(1) != "http://")?
szDir += "http://";?
szDir += "*.*";?
BOOL res = ff.FindFile(szDir);?
while(res)?
{?
res = ff.FindNextFile();?
if(ff.IsDirectory() && !ff.IsDots())?
{?
//如果是一個子目錄,用遞歸繼續(xù)往深一層找?
BrowseDir(ff.GetFilePath());?
}?
else if(!ff.IsDirectory() && !ff.IsDots())?
{?
//顯示當(dāng)前訪問的文件?
str=ff.GetFilePath();?
/* index=str.GetLength();?
//MessageBox(str);?
jjj=str.GetAt(index-3);?
ppp=str.GetAt(index-2);?
ggg=str.GetAt(index-1);?
if(((jjj=='J'||jjj=='j')&&(ppp=='P'||ppp=='p')&&(ggg=='G'||ggg=='g'))||((jjj=='B'||jjj=='b')&&(ppp=='M'||ppp=='m')&&(ggg=='P'||ggg=='p')))
{?
intNumber++;?
cs.Format("%d",intNumber);?
WritePrivateProfileString("圖片目錄文件",cs,str,inifile);*/?
//Sleep(3);?
}?
}?
}?
ff.Close();//關(guān)閉?
//cs.Format("%d",intNumber);?
//WritePrivateProfileString("圖片目錄文件","total",cs,inifile);?
//WritePrivateProfileString("圖片目錄文件","turntowhich","1",inifile);?
}?

//公用目錄對話框****************************************************?

//添加如下程序段?
LPITEMIDLIST pidlBeginAt, pidlDestination ;?
char szPath[ MAX_PATH] ;?
// 取得開始菜單或桌面的PIDL?
SHGetSpecialFolderLocation(AfxGetApp()->m_pMainWnd->m_hWnd,CSIDL_DESKTOP,&pidlBeginAt) ;?
// 取得新建文件夾的父文件夾?
if( !BrowseForFolder(pidlBeginAt ,?
&pidlDestination,?
"請選擇圖片目錄的位置:"))?
{?
return ;?
}?
// 把PIDL轉(zhuǎn)換為路徑名?
SHGetPathFromIDList( pidlDestination, szPath);?
//添加如下函數(shù)?
BOOL BrowseForFolder(?
LPITEMIDLIST pidlRoot,//瀏覽開始處的PIDL?
LPITEMIDLIST *ppidlDestination,?
//瀏覽結(jié)束時所選擇的PIDL?
LPCSTR lpszTitle)//瀏覽對話框中的提示文字?
{?
BROWSEINFO BrInfo ;?
ZeroMemory( &BrInfo, sizeof(BrInfo)) ;?
BrInfo.hwndOwner = HWND_DESKTOP ;?
BrInfo.pidlRoot = pidlRoot ;?
BrInfo.lpszTitle = lpszTitle ;?
//瀏覽文件夾?
*ppidlDestination= SHBrowseForFolder(&BrInfo);?
//用戶選擇了取消按鈕?
if(NULL == *ppidlDestination)?
return FALSE ;/**/?
return TRUE ;?
}?

//讀寫INI/ini文件*************************************************?

//寫入值 字段名 變量名 值 帶目錄文件名?
WritePrivateProfileString("目錄","path",cs, regpath);?
//寫入結(jié)構(gòu)體 字段名 變量名 值 大小 帶目錄文件名?
WritePrivateProfileStruct("字體","font",&LF,sizeof(LOGFONT),regpath);//結(jié)構(gòu)體?
//讀入字符 字段名 變量名 默認(rèn)值 字符緩沖區(qū) 長度 帶目錄文件名?
GetPrivateProfileString("目錄","path","", buffer.GetBuffer(260),260,regpath);?
//讀入整數(shù)值 字段名 變量名 默認(rèn)值 帶目錄文件名?
GetPrivateProfileInt("colors","red",255, regpath);?
//讀入結(jié)構(gòu)體 字段名 變量名 值 大小 帶目錄文件名?
GetPrivateProfileStruct("字體","font",&LF,sizeof(LOGFONT),regpath);?

//位圖操作,畫圖*****************************************************?

CClientDC client(this);?
BITMAP bmpInfo;?
CDC memdc;?
CBitmap picture;?
memdc.CreateCompatibleDC(pdc);?
memdc.SelectObject(&picture);?
CRect re;?
GetClientRect(&re);?
client.BitBlt(0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,&memdc,0,0,SRCCOPY);?
client.SetBkMode(TRANSPARENT);?
client.SetTextColor(RGB(red,green,blue));?
CFont font;?
CFont *oldfont;?
font.CreateFontIndirect(&LF);?
oldfont=client.SelectObject(&font);?
client.DrawText("",//注意這個字符串里如果只有一連串的字母或數(shù)字,沒有空格或中文或標(biāo)點符號,且總長度超過距形寬度,則不能自動換行!!?
&re,DT_CENTER |DT_WORDBREAK);?
client.SelectObject(oldfont);?

//打開EXE/exe文件**********************************************?

ShellExecute(GetSafeHwnd(),?
"open",?
"http://home.jlu.edu.cn/~ygsoft",//改這個文件名就可以了?
NULL,?
NULL,SW_SHOWNORMAL);?
//or?
LPITEMIDLIST pidlBeginAt;?
// 取得桌面的PIDL?
SHGetSpecialFolderLocation(AfxGetApp()->m_pMainWnd->m_hWnd,?
CSIDL_DRIVES//這個標(biāo)志為我的電腦?
,&pidlBeginAt) ;?
SHELLEXECUTEINFO exe;?
ZeroMemory(&exe,sizeof(SHELLEXECUTEINFO));?
exe.cbSize=sizeof(SHELLEXECUTEINFO);?
exe.fMask=SEE_MASK_IDLIST;?
exe.lpVerb="open";?
exe.nShow=SW_SHOWNORMAL;?
exe.lpIDList=pidlBeginAt;?
ShellExecuteEx(&exe);?

//取得函數(shù)不能正常返回的原因字符***************************?

LPVOID lpMsgBuf;?
FormatMessage(?
FORMAT_MESSAGE_ALLOCATE_BUFFER |?
FORMAT_MESSAGE_FROM_SYSTEM |?
FORMAT_MESSAGE_IGNORE_InsertS,?
NULL,?
GetLastError(),?
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language?
(LPTSTR) &lpMsgBuf,?
0,?
NULL?
);?
// Process any inserts in lpMsgBuf.?
// ...?
// Display the string.?
MessageBox((LPCTSTR)lpMsgBuf);?
// Free the buffer.?
LocalFree( lpMsgBuf );?


本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: 驅(qū)動電源

在工業(yè)自動化蓬勃發(fā)展的當(dāng)下,工業(yè)電機作為核心動力設(shè)備,其驅(qū)動電源的性能直接關(guān)系到整個系統(tǒng)的穩(wěn)定性和可靠性。其中,反電動勢抑制與過流保護是驅(qū)動電源設(shè)計中至關(guān)重要的兩個環(huán)節(jié),集成化方案的設(shè)計成為提升電機驅(qū)動性能的關(guān)鍵。

關(guān)鍵字: 工業(yè)電機 驅(qū)動電源

LED 驅(qū)動電源作為 LED 照明系統(tǒng)的 “心臟”,其穩(wěn)定性直接決定了整個照明設(shè)備的使用壽命。然而,在實際應(yīng)用中,LED 驅(qū)動電源易損壞的問題卻十分常見,不僅增加了維護成本,還影響了用戶體驗。要解決這一問題,需從設(shè)計、生...

關(guān)鍵字: 驅(qū)動電源 照明系統(tǒng) 散熱

根據(jù)LED驅(qū)動電源的公式,電感內(nèi)電流波動大小和電感值成反比,輸出紋波和輸出電容值成反比。所以加大電感值和輸出電容值可以減小紋波。

關(guān)鍵字: LED 設(shè)計 驅(qū)動電源

電動汽車(EV)作為新能源汽車的重要代表,正逐漸成為全球汽車產(chǎn)業(yè)的重要發(fā)展方向。電動汽車的核心技術(shù)之一是電機驅(qū)動控制系統(tǒng),而絕緣柵雙極型晶體管(IGBT)作為電機驅(qū)動系統(tǒng)中的關(guān)鍵元件,其性能直接影響到電動汽車的動力性能和...

關(guān)鍵字: 電動汽車 新能源 驅(qū)動電源

在現(xiàn)代城市建設(shè)中,街道及停車場照明作為基礎(chǔ)設(shè)施的重要組成部分,其質(zhì)量和效率直接關(guān)系到城市的公共安全、居民生活質(zhì)量和能源利用效率。隨著科技的進步,高亮度白光發(fā)光二極管(LED)因其獨特的優(yōu)勢逐漸取代傳統(tǒng)光源,成為大功率區(qū)域...

關(guān)鍵字: 發(fā)光二極管 驅(qū)動電源 LED

LED通用照明設(shè)計工程師會遇到許多挑戰(zhàn),如功率密度、功率因數(shù)校正(PFC)、空間受限和可靠性等。

關(guān)鍵字: LED 驅(qū)動電源 功率因數(shù)校正

在LED照明技術(shù)日益普及的今天,LED驅(qū)動電源的電磁干擾(EMI)問題成為了一個不可忽視的挑戰(zhàn)。電磁干擾不僅會影響LED燈具的正常工作,還可能對周圍電子設(shè)備造成不利影響,甚至引發(fā)系統(tǒng)故障。因此,采取有效的硬件措施來解決L...

關(guān)鍵字: LED照明技術(shù) 電磁干擾 驅(qū)動電源

開關(guān)電源具有效率高的特性,而且開關(guān)電源的變壓器體積比串聯(lián)穩(wěn)壓型電源的要小得多,電源電路比較整潔,整機重量也有所下降,所以,現(xiàn)在的LED驅(qū)動電源

關(guān)鍵字: LED 驅(qū)動電源 開關(guān)電源

LED驅(qū)動電源是把電源供應(yīng)轉(zhuǎn)換為特定的電壓電流以驅(qū)動LED發(fā)光的電壓轉(zhuǎn)換器,通常情況下:LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: LED 隧道燈 驅(qū)動電源
關(guān)閉