《操作系统》程序源代码Word下载.docx

上传人:b****2 文档编号:4511126 上传时间:2023-05-03 格式:DOCX 页数:44 大小:23.49KB
下载 相关 举报
《操作系统》程序源代码Word下载.docx_第1页
第1页 / 共44页
《操作系统》程序源代码Word下载.docx_第2页
第2页 / 共44页
《操作系统》程序源代码Word下载.docx_第3页
第3页 / 共44页
《操作系统》程序源代码Word下载.docx_第4页
第4页 / 共44页
《操作系统》程序源代码Word下载.docx_第5页
第5页 / 共44页
《操作系统》程序源代码Word下载.docx_第6页
第6页 / 共44页
《操作系统》程序源代码Word下载.docx_第7页
第7页 / 共44页
《操作系统》程序源代码Word下载.docx_第8页
第8页 / 共44页
《操作系统》程序源代码Word下载.docx_第9页
第9页 / 共44页
《操作系统》程序源代码Word下载.docx_第10页
第10页 / 共44页
《操作系统》程序源代码Word下载.docx_第11页
第11页 / 共44页
《操作系统》程序源代码Word下载.docx_第12页
第12页 / 共44页
《操作系统》程序源代码Word下载.docx_第13页
第13页 / 共44页
《操作系统》程序源代码Word下载.docx_第14页
第14页 / 共44页
《操作系统》程序源代码Word下载.docx_第15页
第15页 / 共44页
《操作系统》程序源代码Word下载.docx_第16页
第16页 / 共44页
《操作系统》程序源代码Word下载.docx_第17页
第17页 / 共44页
《操作系统》程序源代码Word下载.docx_第18页
第18页 / 共44页
《操作系统》程序源代码Word下载.docx_第19页
第19页 / 共44页
《操作系统》程序源代码Word下载.docx_第20页
第20页 / 共44页
亲,该文档总共44页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

《操作系统》程序源代码Word下载.docx

《《操作系统》程序源代码Word下载.docx》由会员分享,可在线阅读,更多相关《《操作系统》程序源代码Word下载.docx(44页珍藏版)》请在冰点文库上搜索。

《操作系统》程序源代码Word下载.docx

m_path="

ringout.wav"

;

ASSERT((IDM_ABOUTBOX&

0xFFF0)==IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX<

0xF000);

CMenu*pSysMenu=GetSystemMenu(FALSE);

if(pSysMenu!

=NULL)

CStringstrAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if(!

strAboutMenu.IsEmpty())

{

pSysMenu->

AppendMenu(MF_SEPARATOR);

AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

}

SetIcon(m_hIcon,TRUE);

//Setbigicon

SetIcon(m_hIcon,FALSE);

//Setsmallicon

CFont*f;

f=newCFont;

f->

CreateFont(30,//nHeight

0,//nWidth

0,//nEscapement

0,//nOrientation

FW_BOLD,//nWeight

TRUE,//bItalic

TRUE,//bUnderline

0,//cStrikeOut

ANSI_CHARSET,//nCharSet

OUT_DEFAULT_PRECIS,//nOutPrecision

CLIP_DEFAULT_PRECIS,//nClipPrecision

DEFAULT_QUALITY,//nQuality

DEFAULT_PITCH|FF_SWISS,//nPitchAndFamily

_T("

Arial"

));

//lpszFac

GetDlgItem(IDC_STATIC1)->

SetFont(f);

SetWindowText("

欢迎使用Windows定时管理系统"

);

CTimetime;

time=CTime:

GetCurrentTime();

CStrings=time.Format("

%H:

%M:

%S"

GetDlgItem(IDC_STATIC4)->

SetWindowText(s);

//启动定时器

SetTimer(1,1000,NULL);

CheckRadioButton(IDC_RADIO1,IDC_RADIO3,IDC_RADIO1);

m_tnid.cbSize=sizeof(NOTIFYICONDATA);

//定义结构的成员变量

m_tnid.hWnd=this->

m_hWnd;

m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;

m_tnid.uCallbackMessage=MYWM_NOTIFYICON;

//用户定义的回调消息

_tcscpy(m_tnid.szTip,_T("

定时关机程序,制作人:

一江春水"

hIcon=m_hIcon;

m_tnid.hIcon=hIcon;

if(hIcon):

DestroyIcon(hIcon);

GetWindowRect(&

m_rectFull);

m_rectHalf=m_rectFull;

//calculateourhalfsizebasedonbottomof"

More"

button

CRectrect;

m_ctrlMoreButton.GetWindowRect(&

rect);

m_rectHalf.bottom=rect.bottom+10;

//+10forcosmetics

ToggleSize();

returnTRUE;

//returnTRUEunlessyousetthefocustoacontrol

}

voidCTimeOffDlg:

OnSysCommand(UINTnID,LPARAMlParam)

if((nID&

0xFFF0)==IDM_ABOUTBOX)

CAboutDlgdlgAbout;

dlgAbout.DoModal();

CDialog:

OnSysCommand(nID,lParam);

OnPaint()

if(IsIconic())

CPaintDCdc(this);

//devicecontextforpainting

SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);

intcxIcon=GetSystemMetrics(SM_CXICON);

intcyIcon=GetSystemMetrics(SM_CYICON);

CRectrect;

GetClientRect(&

intx=(rect.Width()-cxIcon+1)/2;

inty=(rect.Height()-cyIcon+1)/2;

dc.DrawIcon(x,y,m_hIcon);

OnPaint();

HCURSORCTimeOffDlg:

OnQueryDragIcon()

return(HCURSOR)m_hIcon;

OnCancel()

if(MessageBox("

真的要退出吗?

"

"

你确信?

MB_OKCANCEL|MB_ICONQUESTION)==IDOK)

OnCancel();

OnPowOff()

PowerOff();

OnChaUser()

ExitUser();

OnReStart()

ReStart();

OnSetTime()

SetTimedlg;

dlg.DoModal();

OnButton1()

UpdateData(true);

CStrings;

if(m_time1=="

||m_time2=="

||m_time3=="

MessageBox("

请选择正确的时间"

选择"

s=m_time1+"

+m_time2+"

+m_time3;

m_str=s;

if(CheckRadio()==1)

s="

你选择的关机时间是:

+s;

if(CheckRadio()==2)

s="

你选择的注销时间是:

if(CheckRadio()==3)

你选择重启时间是:

GetDlgItem(IDC_STATIC2)->

OnTimer(UINTnIDEvent)

CStringhour_minS=m_TimeS.Format("

%M"

CStringminS=m_TimeS.Format("

CStringhour_min=time.Format("

CStringmin=time.Format("

CStringsec=time.Format("

if(s==m_str)

PowerOff();

if(IsDlgButtonChecked(IDC_RADIO4))

if(min=="

00"

&

sec=="

PlaySound(m_path,NULL,SND_FILENAME|SND_ASYNC);

if(IsDlgButtonChecked(IDC_RADIO5))

if((min=="

||min=="

30"

)&

if(hour_minS==hour_min)

OnTimer(nIDEvent);

OnDestroy()

KillTimer

(1);

OnClose();

intCTimeOffDlg:

CheckRadio()

if(IsDlgButtonChecked(IDC_RADIO1))

return1;

elseif(IsDlgButtonChecked(IDC_RADIO2))

return2;

return3;

LRESULTCTimeOffDlg:

WindowProc(UINTmessage,WPARAMwParam,LPARAMlParam)

if(lParam==WM_LBUTTONUP)

LPPOINTlpoint=newtagPOINT;

GetCursorPos(lpoint);

CMenumenu;

menu.CreatePopupMenu();

menu.AppendMenu(MF_STRING,WM_DESTROY,"

退出"

//menu.AppendMenu(MF_SEPARATOR);

//menu.AppendMenu(MF_STRING,WM_THREADEXIT,"

关闭窗口"

:

SetForegroundWindow(m_tnid.hWnd);

menu.TrackPopupMenu(TPM_LEFTALIGN,lpoint->

x,lpoint->

y,this);

HMENUhmenu=menu.Detach();

menu.DestroyMenu();

deletelpoint;

elseif((message==WM_SYSCOMMAND)&

(wParam==SC_MINIMIZE))//如果是系统消息

this->

ShowWindow(SW_HIDE);

:

Shell_NotifyIcon(NIM_ADD,&

m_tnid);

returntrue;

elseif((message==MYWM_NOTIFYICON)&

(lParam==WM_LBUTTONDBLCLK))//如果是用户定义的消息

ShowWindow(SW_SHOW);

SetActiveWindow();

//双击并且出现在最上面

//:

Shell_NotifyIcon(NIM_DELETE,&

returnCDialog:

WindowProc(message,wParam,lParam);

returnCDialog:

OnCheckSound()

//TODO:

Addyourcontrolnotificationhandlercodehere

CFileDialogDlgOpenFile(TRUE,"

.wav"

NULL,

OFN_EXPLORER,

"

波表文件(*.Wav)|*.Wav"

this);

intiResult=DlgOpenFile.DoModal();

if(iResult==IDOK)

CStringcstrFilePath=DlgOpenFile.GetPathName();

m_path=cstrFilePath;

UpdateData(false);

OnLisen()

OnMoreButton()

ToggleSize()

CStringstr;

if(m_bToggleSize)

str="

<

&

简洁版"

rect=m_rectFull;

闹铃设置>

>

rect=m_rectHalf;

SetWindowPos(NULL,0,0,rect.Width(),rect.Height(),SWP_NOZORDER|SWP_NOMOVE);

m_ctrlMoreButton.SetWindowText(str);

m_bToggleSize=!

m_bToggleSize;

实训2程序源代码

#include<

stdio.h>

iostream.h>

windows.h>

#defineBufferSize15

charBuffer[BufferSize];

inthead,tail=0;

//Buffer数组下标

intcount;

//被使用的缓冲区数量

HANDLEhMutex;

HANDLEhNotFullEvent,hNotEmptyEvent;

//用来同步生产者和消费者线程

//缓冲区存储情况

//------------------------------------------------

voiddisplay(chara[15])

{inti;

cout<

缓冲区存储情况如下:

endl;

for(i=14;

i>

=0;

i--)

\t|----"

a[i]<

----|"

voidProducer1()

charch;

charp1[]={'

a'

'

b'

c'

d'

e'

f'

g'

h'

i'

j'

};

if(tail<

15){

for(i=0;

i<

10;

i++){

while

(1){

WaitForSingleObject(hMutex,INFINITE);

if(count==BufferSize){//缓冲区满

ReleaseMutex(hMutex);

//等待直到缓冲区非满

WaitForSingleObject(hNotFullEvent,INFINITE);

continue;

}//if

//得到互斥锁且缓冲区非满,跳出while循环

break;

}//while

if(tail>

14){

缓冲区已满,不能再放入数据!

//结束临界区

PulseEvent(hNotEmptyEvent);

//唤醒消费者线程

}//if

else{

//得到互斥锁且缓冲区非满,开始产生新数据

生产者p1:

\t"

p1[i]<

Buffer[tail]=p1[i];

tail=(tail+1)%BufferSize;

///存放于缓冲区的位置

display(Buffer);

//tail++;

count++;

请按ENTER继续...."

ch=getchar();

}//else

}//for

}//if

}//p1_Producer

voidProducer2()

charp2[]={'

0'

1'

2'

3'

4'

5'

6'

7'

8'

9'

if(count==BufferSize){//缓冲区满

//等待直到缓冲区非满

WaitForSingleObject(hNotFullEvent,INFINITE);

//得到互斥锁且缓冲区非满,跳出while循环

}//while

if(tail>

缓冲区已满,不能再存入数据!

程序结束!

//唤醒消费者线程}//if

//得到互斥锁且缓冲区非满,开始产生新数据

生产者p2:

p2[i]<

Buffer[tail]=p2[i];

//tail++;

//结束临界区

//唤醒消费者线程

}//else

}//for

}//

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2