• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

C# İle Sanal Disk Oluşturma

ByOnur58

MFC Üyesi
Üyelik Tarihi
7 Ocak 2015
Mesajlar
2,114
MFC Puanı
10
Yaş
28
Merhaba Arkadaşlar;

Hadi Başlayalım.
Öncelikli olarak aşağıda bulunan class dosyasını indirin ve projenize ekleyin..

Class Kodu

v o i d (boşluksuz) = ****

Kod:
using System;
using System.Text;
using System.ComponentModel;
using System.Runtime.InteropServices;

static class Subst
{
//turkhackteam

public static **** MapDrive(char letter, string path)
{
if (!DefineDosDevice(0, devName(letter), path))
throw new Win32Exception();
}
public static **** UnmapDrive(char letter)
{
if (!DefineDosDevice(2, devName(letter), null))
throw new Win32Exception();
}
public static string GetDriveMapping(char letter)
{
var sb = new StringBuilder(259);
if (QueryDosDevice(devName(letter), sb, sb.Capacity) == 0)
{
// Return empty string if the drive is not mapped
int err = Marshal.GetLastWin32Error();
if (err == 2) return "";
throw new Win32Exception();
}
return sb.ToString().Substring(4);
}


private static string devName(char letter)
{
return new string(char.ToUpper(letter), 1) + ":";
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool DefineDosDevice(int flags, string devname, string path);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int QueryDosDevice(string devname, StringBuilder buffer, int bufSize);
}


Son olarak;
forma 1 buton ekleyin ve

Kod:
// Sürücü Oluşturmak İçin

Subst.MapDrive('z', @"c:");
Console.WriteLine(Subst.GetDriveMapping('z'));
// Sürücüyü Kaldırmak İçin
Subst.UnmapDrive('x');​
 
Geri
Üst