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

عرض اسم المستخدم في Textbox

مغلق
بدأه العقده في 31 يناير 2008 · 3 رد · 640 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ما هو الكود الذي يقوم بعرض اسم المستخدم الذي قام بتسجيل الدخول على الويندوز في مربع Textbox في برنامجي .

ليس كل ما يتمناه المرء يدركه

arabteam2000.gif

#2

وجدت هذا الكود فهل اجد من يحوله لي من vb.net الى #C

//**************************************
	//	 
	// Name: Convert SID to Username
	// Description:I got this from a MS samp
	//	 le but I spent over a week looking for i
	//	 t. This code will take a SID (Security I
	//	 D) and return the corosponding Domain & 
	//	 Username. For information purposes, a SI
	//	 D is the actual account name for a user 
	//	 account on a Windows computer or Domain.
	//	 The same way a www domain name is used t
	//	 o map an IP address. The only catch is y
	//	 ou have to be logged onto the domain tha
	//	 t you are looking up SID information on.
	//	 I'm working on a change that will allow 
	//	 you to lookup SID's on other domains now
	//	 .
	// By: niconX
	//
	// Inputs:SID
	//
	// Returns:UserName
	//
	//This code is copyrighted and has	// limited warranties.Please see http://
	//	 www.Planet-Source-Code.com/vb/scripts/Sh
	//	 owCode.asp?txtCodeId=2653&lngWId=10	//for details.	//**************************************
	//	 

	Imports System
	Imports System.Runtime.InteropServices
	Private Declare Unicode Function _
	ConvertStringSidToSidW Lib "advapi32.dll" (ByVal StringSID As String, _
	ByRef SID As IntPtr) As Boolean
	Private Declare Unicode Function _
	LookupAccountSidW Lib "advapi32.dll" (ByVal lpSystemName As String, _
	ByVal SID As IntPtr, _
	ByVal Name As Text.StringBuilder, _
	ByRef cbName As Long, _
	ByVal DomainName As Text.StringBuilder, _
	ByRef cbDomainName As Long, _
	ByRef psUse As Integer) As Boolean
	Shared Function GetName(ByVal SID As String) As String
	Const size As Integer = 255
	Dim domainName As String
	Dim userName As String
	Dim cbUserName As Long = size
	Dim cbDomainName As Long = size
	Dim ptrSID As New IntPtr(0)
	Dim psUse As Integer = 0
	Dim bufName As New Text.StringBuilder(size)
	Dim bufDomain As New Text.StringBuilder(size)
	If ConvertStringSidToSidW(SID, ptrSID) Then
	If LookupAccountSidW(String.Empty, _
	ptrSID, bufName, _
	cbUserName, bufDomain, _
	cbDomainName, psUse) Then
	userName = bufName.ToString
	domainName = bufDomain.ToString
	Return String.Format("{0}\{1}", domainName, userName)
	Else
	Return ""
	End If
	Else
	Return ""
	End If
	End Function

ليس كل ما يتمناه المرء يدركه

arabteam2000.gif

#3

السلام عليكم ورحمه الله وبركاته

اعمل بحث علي جوجل واكتب convert vb.net to #C

ان شاء الله هتجد ما تريد

او ادخل علي هذا الرابط

http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

#4

الموقع للاسف يظهر لي خطأ اثناء التحويل من كود vb الى #C ووجدت ايضا هذا الكود في نفس الموقع والذي يعتبر مختصر اكثر من الذي وضعته في مشاركتي

The code below allows you to retreive the current logged on user on a PC

Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetUserName() As String
Dim UserName As String * 255
	GetUserNameA UserName, 255
	GetUserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
End Function

وايضا عندما وضعته في لتحويله من vb الى #C ظهر خطا اثناء التحويل .

اشكر لك مشاركتك وارجوا ان اصل لحل بمساعدتكم .

تم تعديل هذه المشاركة بواسطة العقده في 1 فبراير 2008 في 14:27

ليس كل ما يتمناه المرء يدركه

arabteam2000.gif

هذا الموضوع مغلق.

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