problem to importing DLL files
-
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
-
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
cppwxwidgetsss wrote:
Attribute 'StructLayout' is not valid on this declaration type
Now how about this: a StructLayout tells something about the layout of a struct you define. Throw it away. BTW: an app should not mess around with the system settings, such as Regional Settings, current date/time, etc. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
cppwxwidgetsss wrote:
Attribute 'StructLayout' is not valid on this declaration type
Now how about this: a StructLayout tells something about the layout of a struct you define. Throw it away. BTW: an app should not mess around with the system settings, such as Regional Settings, current date/time, etc. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
Luc Pattyn wrote:
an app should not mess around with the system settings, such as Regional Settings, current date/time, etc.
Hear hear!