الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Need Copyfile Function To Windows Directory Please

بدأه x10 في 19 مايو 2008 · 2 رد · 754 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

im so sorry for writing in english because my windows does not support arabic at these time

:\ new to vb programming i want a function for copying a file from any place to windows directory without use c:\ or d:\

i mean if i copy my file to a windows partition without using c:\

how can i do it if i dont know the windows directory

i have tried

copy file d:\myfile, %windir%

but does not make sence

الثـورة معني وأسم وفعل

قــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــادمون ......

#2

عليك اولا استخدام دالة لمعرفة ماهو مسار الويندوز هل C , D ...

مثلا لمعرفة مسار ملفي Windows و System استعمل :

Option Explicit
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
	"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
	"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" ( _
	ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Load()
	Dim W
	Dim WindowsD As String
	WindowsD = Space(144)
	W = GetWindowsDirectory(WindowsD, 144)
	Text1.Text = WindowsD

	Dim S
	Dim SystemD As String
	SystemD = Space(144)
	S = GetSystemDirectory(SystemD, 144)
	Text2.Text = SystemD

	Dim N
	Dim UserN As String
	UserN = Space(144)
	N = GetUserName(UserN, 144)
	Text3.Text = UserN
End Sub

لنقل ملف :

Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
Private Sub Command1_Click()
MoveFile "c:\my documents\a.txt", "c:\a.txt"
End Sub

لنسخ ملف :

Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Sub Command1_Click()
CopyFile "c:\my documents\b.txt", "c:\b.txt", False
End Sub
اقتباس
If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut

Albert Einstein

مدخل إلى برمجة وتصميم الألعاب : كيف أبدأ ؟

مواضيع مشابهة