簡體   English   中英

為操作系統 Cosmos C# 創建安裝程序

[英]Creating installer for operating system Cosmos C#

我需要在 Cosmos 內核中為我的操作系統創建一個安裝程序,但我不知道從哪里開始或如何創建它。

[查看我的操作系統]

https://www.mediafire.com/file/3nr6pbjfg7p1gfq/GoPixelOS.iso/file

我想在機器上安裝操作系統,我該怎么做?

我想我可以幫助你。 但它實際上創造了一個新用戶。 但它仍然需要安裝。 但這不適用於沒有 Filesystem.vmdk 的另一台計算機。 也許它只是一個虛擬文件系統

  1. 首先你需要一個文件系統

  2. 你還需要 System.io

  3. 在寫這段代碼之前⬇

     if (!File.Exists("0:\\\\youros\\\\System.txt")) //you will need Using.System.io and ! mean not equal { Console.Clear(); Console.WriteLine("YourOS will be install in your pc"); Console.WriteLine("Create a username and password:"); Console.Write("Username: "); string username = Console.ReadLine(); Console.Write("Password: "); string cPassword = Console.ReadLine(); Console.Write(username +"> "); //when your put username variable it should look like this "The user name: " Console.WriteLine("Creating System Directory..."); //Creating Directory or folder fs.CreateDirectory("0:\\\\yourOS\\\\"); Console.WriteLine("Creating File for user"); fs.CreateFile("0:\\\\yourOS\\\\System.txt"); //Creating File System fs.CreateFile("0:\\\\yourOS\\\\users.db"); fs.CreateFile("0:\\\\yourOS\\\\password.db"); //creating a password files Console.WriteLine("Setting User Preferences..."); File.WriteAllText("0:\\\\yourOS\\\\System.txt", write); File.WriteAllText("0:\\\\yourOS\\\\users.db", username); ` //This will save username File.WriteAllText("0:\\\\yourOS\\\\password.db", cPassword); //this one will save the user password Console.WriteLine("Reboot ONEOS in 3 seconds"); Cosmos.HAL.Global.PIT.Wait(3000); Sys.Power.Reboot(); //when the installation done it will reboot` else //after reboot it will go to else and just leave it blank. it will just go to run() after the else { password = File.ReadAllText("0:\\\\oneos\\\\password.db"); //this will show the Console.Write("Type your password: ") var type Console.ReadLine(); if (type == password) { //just leave it blank. it will go to protected override void run() } else } Sys.Power.Reboot(); //this will reboot the OS if user type wrong password { }

那是為了安裝,但如果你想讓安裝更有用,你將需要這個

//protected override void Run()
text = File.ReadAllText("0:\\oneos\\users.db"); //this will show the username
Console.Write(text + "> ");
var input = Console.ReadLine();

那就是如果你想讓它顯示錯誤,如果有錯誤,就把 try 和 catch 放到你的操作系統上。 如果你能理解這一點,你可以讓操作系統有用戶選擇,比如 Windows 登錄屏幕。

如果有問題請告訴我

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM