|
|
Hello Samira,
Here is a code with you can get the Mac adrress of local machine
i hope this will help full to you.
private static string GetMacAddress()
{
string macAddr = "";
try
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapter");
foreach (ManagementObject mo in mc.GetInstances())
{
macAddr = mo["MACAddress"] as string;
if (macAddr != null && macAddr.Trim() != "")
return macAddr;
}
}
catch (Exception exp)
{
}
Random ranGenerator = new Random(6);
macAddr = ranGenerator.Next(100000, 999999).ToString();
return macAddr;
}
Regards,
Irfan.
|
|
|
|
|
hello
i have developed a desktop application in C#.net 2.0 where i need to retrieve all installed browser plugins names in the loacal machine.That means the application will retrieve all the installed browser plugin names from the pc where this application run.
Please helpme to find a way to retrive the installed plugin names.
Thanks and regards
Sourav
|
|
|
|
|
:|Hi,
can any one give me a win32 api and also a control or library that can get the NEC MAC address from the Hardware itself not from the registry. it will be good if it can be used in C#.
May god give u good health and knowledge.
|
|
|
|
|
Hi, I'm wondering how I can remove the 'Close' button on a modal dialog. The reason is I don't want the user to accidentally close this partiulcar window, or at least display a confirmation to the user to ask whether if they really want to close it. I can't do that with the Form_Closing event as it stills closes it.
|
|
|
|
|
write your code int Dispose Method.e.g
protected override void Dispose( bool disposing )<br />
{<br />
<br />
if(DialogResult.Yes==MessageBox.Show("Do you Want to quit?","Quit",MessageBoxButtons.YesNo))<br />
{<br />
if( disposing )<br />
{<br />
if(components != null)<br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
else<br />
return;<br />
}<br />
|
|
|
|
|
|
When the Form is getting disposed it is already closed. So this doesn't work. Dispose is about freeing resources - no more no less.
Robert
|
|
|
|
|
Hi,
why can't you do this with the Closing event? This is exactly what it is meant for. Post some code. You have most probably some mistake in your code.
Robert
|
|
|
|
|
Robert, I don’t want say this but I have to say Check your Premise
|
|
|
|
|
Hi,
even after looking in a dictionary about premise I don't really get what you want to say. May be my mistake because english is not my native language. Could you reformulate?
Robert
|
|
|
|
|
bankai123 wrote: I can't do that with the Form_Closing event as it stills closes it.
You can. If the user doesn't want to close the form, assign true to the Cancel property of the passed CancelEventArgs instance.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks, that's exactly what I was looking for. I gotta learn to read MSDN better :P
|
|
|
|
|
I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code
<br />
FormB formb = new FormB();<br />
FormB.Show();<br />
in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB
Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;)
|
|
|
|
|
There are many ways to accomplish your task.
1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you.
2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it.
3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it.
You can use any of the above mentioned way. Hope it helps.
Regards
Khalid
|
|
|
|
|
Thanks man, i am trying the method u suggest
|
|
|
|
|
Hi every body,
I have to call a DLL that contain a function follow:
typedef struct _ProStruct {
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
} ProStruct
int MyBuggingFunc(long bDebugMode,ProStruct* pProStruct,TCHAR* Location);
When I call it in C# 2005 such as:
public struct ProStruct{
long hProcess;
long hThread;
int dwProcessId;
int dwThreadId;
}
[DllImport("MyBugFunc.dll",CallingConvention = CallingConvention.Cdecl)]
public static extern int MyBuggingFunc(int bDebugMode,
ProStruct pProStruct,String Location);
private void Form1_Load(object sender, EventArgs e)
{
try
{
ProStruct pPI = new ProStruct();
int ret = MyBuggingFunc((int)(1), pPI, "MyTest.dkt");
}
catch (Exception loi)
{
MessageBox.Show(loi.Message);
}
}
When the form is loaded, there is an error occurs:
"PInvokeStackImbalance was detected
Message: A call to PInvoke function 'WindowsApplication4!WindowsApplication4.Form1::MyBuggingFunc has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
"
I assume some parameters have incorrect type with convention in calling DLL from third party DLL. I tried to fix it many times but I get the the same error.
Could you help me to resolve my problem?
Thanks all of you!
Hoang Quoc Dat
|
|
|
|
|
Your long types are what's wrong. In C++, long is 32-bits long. In C#, long is an alias for System.Int64, which is 64 bits long.
Try this:
public struct ProStruct{
int hProcess;
int hThread;
int dwProcessId;
int dwThreadId;
}
|
|
|
|
|
Thank you very much.
I've tried to fix my problem as you shown but the same error uccurs.
Can you have any ideals to help me?
Thanks again!
Hoang Quoc Dat
|
|
|
|
|
public struct ProStruct{int hProcess;int hThread;int dwProcessId;int dwThreadId;}
Thank you very much.
But I've tried it before but the same error occurs.
Could you have any other ways?
Thanks
Hoang Quoc Dat
|
|
|
|
|
Try this:
[StructLayout(LayoutKind.Sequential)]
public struct ProStruct{
IntPtr hProcess;
IntPtr hThread;
int dwProcessId;
int dwThreadId;
}
|
|
|
|
|
Hi,
I have a situation where I have a class which I would like to be visible within its assembly, but only to be able to be created by a single other class. Ideally I would make the constructor private and the other class a friend and this would solve the problem, but that's not possible in c#. I was hoping there may be some special property of a nested class to allow this but it doesn't seem so.
Can anyone think of another way to do this?
Thanks,
Matt
|
|
|
|
|
There is no clean way. C# sucks.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: There is no clean way. C# sucks.
Aww man...come on now. I come from a C++ and Java background; to me, C# rocks.
|
|
|
|
|
matt cole wrote: I have a situation where I have a class which I would like to be visible within its assembly, but only to be able to be created by a single other class.
Create an interface representing the functionality of the first class. Have the first class implement that functionality as a private class to the second class:
public interface ISomeInterface
{
void DoSomething();
}
public class MyClass
{
private class MyPrivateClass : ISomeInterface
{
public void DoSomething()
{
}
}
public ISomeInterface Create();
{
return new MyPrivateClass();
}
}
Maybe not exactly what you're looking for; you have the interface in your namespace which may not be implemented any where else, but that may not be a problem.
|
|
|
|