المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : problem to importing DLL files



C# Programming
04-05-2009, 11:55 AM
i have a form, i want to change the time and/or date of the system
and now i have found the following code but it just generate errors
i don't know what is exactly the problem
it is not a run time error, it is a compilation error
i am using C# in visual studio 2008
here is the error message :

"Error 39 Attribute 'StructLayout' is not valid on this declaration type. It is only valid on 'class, struct' declarations. D:\visual studio projects\firstCSharp\firstCSharp\settings.cs 16 12 firstCSharp"

here is the code

public partial class settings : Form
{
[StructLayout(LayoutKind.Sequential)]
[DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]

private static extern bool SetSystemTime(ref MyDateTime st);



[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]

private extern static void GetSystemTime(ref MyDateTime sysTime);
please tell me how can i handle this error
thank you everybody in Advance