int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCamdShow)
{
OPENFILENAME ofn
char szFile[MAX_PATH]
ZeroMemory(&ofn, sizeof(ofn))
ofn.lStructSize = sizeof(ofn)
ofn.lpstrFile = szFile
ofn.lpstrFile[0] = TEXT('\0')
ofn.nMaxFile = sizeof(szFile)
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"
ofn.nFilterIndex = 1 //如果改为2的话就会显示txt格式的文件。
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = NULL
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST
if(GetOpenFileName(&ofn))
{
ShellExecute(NULL,"open",ofn.lpstrFile,NULL,NULL,SW_SHOWNORMAL)//第三个参数是要打开的文件的路径,在你打开的时候自动生成并传给函数,再以open的方式打开,打开的方式将以你电脑系统对该类型文件的打开方式有关。
}
return 0
}
如果是本地账户的话,用mail就可以了;或者直接 *** 作/var/spool/mail/user如果是像163,sina,gmail等邮箱的话,shell做不到,你可以考虑用python,直接上网查就有了。比如以下:
#!/usr/local/bin/python
#
# mailh.py
# remember user-pass-stat/list-top-dele/retr-quit
import poplib, getpass, string, sys
host = raw_input("The hostname: ")
if (len(host)) == 0:
host = 'pop3.gmail.com'
username = 'xxxx@gmail.com'
password = 'xxxx'
else:
username = raw_input("your username: ")
password = getpass.getpass()
try:
sess = poplib.POP3(host)
sess.user(username)
sess.pass_(password)
except:
print "O^O, there is an error in opening connection!"
sys.exit()
nMess = sess.stat()[0]
headers = []
for i in range(1, nMess+1):
mesg = sess.top(i,0)
print i, mesg[0]
for j in range(len(mesg[1])):
if mesg[1][j][0:5] == 'From:' or mesg[1][j][0:5] == 'Date:' \
or mesg[1][j][0:8] == 'Subject:' or mesg[1][j][0:3] == 'To:':
print mesg[1][j]
headers.append(mesg[1][j])
if nMess>0:
print "Received %i message total."%(nMess)
else:
print "Nop, no mail on ", host, "for", username
sess.quit()
if [ $# -ne 1 ]then
echo "输入一个整数"
exit 1
fi
i=1
sum=1
while [ $i -le $1 ]
do
sum=$((sum * i))
i=$((i+1))
done
echo $sum
这样可实现你的要求
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)