C語言程序部分:
#include <stdio.h>
#include <conio.h>
#include<windows.h>
int main ()
{
unsigned long time = 0;
char chr[50];
time = GetTickCount();
int hm = time / 3600000; //hm為小時數
int ms = time % 3600000 / 60000; //ms為分鐘數
int se = time % 3600000 % 60000 / 1000; //se為秒數(除以1000是因為time精確到毫秒)
printf("本次開機用時%2d:%2d:%2d", hm, ms, se); //輸出時、分、秒);
sprintf(chr, "wscript voice.VBS %d %d", ms, se);
system(chr);
exit(0);
return 0;
}
VBS腳本部分:
Dim args
set args = wscript.arguments
CreateObject("SAPI.SpVoice").Speak "本次開機用時 "&args(0)&"分"&args(1)&"秒"
將VBS腳本保存為voice.VBS與可執行文件保存在同一目錄下, 再將可執行文件設為開機啟動就可以了.