Hi!!!!!
I have made a exe file of my C# project.....
can anyone tell me how can my application read the mac address of target{user} system.........Also how can It be valid only for 1 year i.e. how to add the code of subscription in my application that as user install my software then it should be valid for 1 yr only and no other person could install it on his system.......
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Aug 12, 2009, 4:52 AM EDT
Here you can Simply Do it Without any Management Object Coding Simple to Understand Code :)
and you can also Locate MAC of Connected other pcs just Change that StartInfo.Argument Line according to your need
and you are done :)
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "getmac.exe";
p.StartInfo.Arguments = @"/s YourServer /u Domain\ComputerName /p YourPassword";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit(200);
// Extract MACS from output
Regex re = new Regex("([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])");
MatchCollection mc = re.Matches(p.StandardOutput.ReadToEnd());
foreach (Match m in mc)
{
listBox1.Items.Add(m.ToString());
}
}
Roei BarRank #1,271 · 1.4K reputationPosted Aug 11, 2009, 12:12 PM EDT
System.Management.ManagementClass mc = default(System.Management.ManagementClass); ManagementObject mo = default(ManagementObject); mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc = mc.GetInstances(); foreach (var mo in moc) { if (mo.Item("IPEnabled") == true) { Adapter.Items.Add("MAC " + mo.Item("MacAddress").ToString()); } }and for Time Limitation you can use this code, Change is as needed and use this class on applicationStart:
using System; namespace expireApp { public class expire { private double _daysSelect; private string _dateInstall; private TimeSpan _daysRemaining; private string errors = "NONE"; private string _evaluationVersion = "OFF"; private DateTime dateInstalled; private DateTime dateEnd; private bool status; public double daysSelect { set { _daysSelect = value; } } public string dateInstall { set { _dateInstall = value; } } public bool expireStatus { get { compareDate(); return(status); } } public string errorStatus { get { errorCheck(); return(errors); } } public double daysRemaining { get { _daysRemaining = dateEnd.Subtract(getCurrentDate()); return(_daysRemaining.TotalDays + 1); } } private void errorCheck() { if (_evaluationVersion != "ON" && _evaluationVersion != "OFF" && _evaluationVersion == "") { errors = "_evaluationVersion Tag is not properly set!!!"; } if (_evaluationVersion == "OFF") { errors = "_evaluationVersion Tag property is set to OFF"; } if (_daysSelect == 0) { errors = "Expiration days cannot be zero or empty !!!"; } if (_dateInstall == "") { errors = "Installation date is empty or null value !!!"; } } private void start() { if (_evaluationVersion == "ON") { if (_daysSelect != 0 && _dateInstall != "" ) { parseTheDate(_dateInstall); getDateEnd(); } else { errorCheck(); } } else if (_evaluationVersion == "OFF") { errorCheck(); } } public string evaluationVersion { set { _evaluationVersion = value; start(); } } private void parseTheDate(string localdate) { try { dateInstalled = DateTime.Parse(localdate); } catch(Exception e) { errors = e.ToString(); } } // retun the current date private DateTime getCurrentDate() { return(DateTime.Today); } // compare the dates private void compareDate() { DateTime dateExpire; DateTime dateCurrent; bool checkStatus = false; dateExpire = dateEnd; dateCurrent = getCurrentDate(); if (dateCurrent dateExpire) { checkStatus = false; } status = checkStatus; } // find the last date private void getDateEnd() { double i = 0; DateTime dateLast; dateLast = dateInstalled.AddDays(i); while (iKirtan PatelRank #292 · 8.6K reputationPosted Aug 11, 2009, 12:53 PM EDT
do you need mac of remote computer that is connected to your computer through lan ?
vinni jain109 reputationPosted Aug 11, 2009, 9:36 PM EDT
Yaa give the code for finding the mac address of remote computer..........
also tell me since i have made teh exe file of my project , so tell me where and how should I add this code in my application...
vinni jain109 reputationPosted Aug 12, 2009, 8:45 AM EDT
Kirtan can u plz tell me that where should i add the code in my project which Roei Bar has given, such that when user installs my application,firstly it reads the system's mac address and subscribe for 1 yr.
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 12, 2009, 10:45 AM EDT
so i don't thing it will work because we have to store data about installation date and current date some where
then at every run of application that application checks that application expired or not .
i m working on your code right now will post your code here when it is completed
vinni jain109 reputationPosted Aug 23, 2009, 11:01 PM EDT
You haven't replied yet............
I am waiting for your reply.........
Kindly reply......
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 24, 2009, 3:40 AM EDT
as i know now you know that How to Write and Read in Registry :)
While you Install your Application Using "Setup Project" You will Create Two Registry Key One For Storing "Installation Date" and One For storing "Last Application Open Date"
Date Between Install Date And last opened Date in Registry then allow Further Access and Application Always Writes The Current Date to Last Opened Date key in Registry after verifying the Dates at Start up(On Load).
If somebody changes the system date then application will check if the application latest opened date and Difference of
if the system date is less than the last opened date then update you application installed date to 1/1/1900 this way they can't even open the application even if it backdated.
vinni jain109 reputationPosted Aug 24, 2009, 3:53 AM EDT
vinni jain109 reputationPosted Aug 28, 2009, 9:54 PM EDT