|
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
|
|
|
|
|
Luc Pattyn wrote: an app should not mess around with the system settings, such as Regional Settings, current date/time, etc.
Hear hear!
|
|
|
|
|
Hello there,
I am having a little problem in implementing the separator line in Windows Form. I have taken a label control in my form and have set its height to 2 pixels and borderStyle to fixed3D and set the AutoSize property of the form to False. However, although a Bevel line is created in place of the label, but the line is not Wide. Its only a few centimetres wide. I have set the label wide property to 100-150 but no changes had taken place. Note that I am not implementing any coding here. I am just setting the property of the label. Please tell me, how can I widen the label (now bevel line) on my form according to my wish.
Your help will really be appreciated,
Thanx....
Rajdeep.NET
|
|
|
|
|
Dude, just paint a separator
In the OnPaint event handler of the form do the following
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Brushes.Gray), X1, Y1, X2, Y2);
}
Where X1, Y1, X2, Y2 are the coordinates were the line will be drawn
Welcome to the world of GDI, have fun
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Just a Minute!
How can I paint a separator? U said to pase the code in the OpPaint Event Handler, But I did not find any control in the toolbox like the OnPaint!
Help please,
this project's gotta do with my life and death....
plz plz plz help me....
Rajdeep.NET
|
|
|
|
|
Just a Minute!
How can I paint a separator? U said to paste the code in the OpPaint Event Handler, But I did not find any control in the toolbox like the OnPaint!
Help please,
this project's gotta do with my life and death....
plz plz plz help me....
Rajdeep.NET
|
|
|
|
|
Add a Panel, set its height, anchor it left and right, and set some BackColor.
And please go buy a tutorial book on C# and study that; in less than a week you would have learned ten times more than you have last week by asking all kinds of elementary questions.
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
|
|
|
|
|
This is from memory, so you may have to adapt to what's actually there, but it should be close:
0) Put a label control on the form.
1) Set the border style property to Fixed 3D.
2) Set the Auto Size property to false.
3) Set the height (or width) to 2px (you have to physically type this because the designer won't let you make it that small by dragging the border with the mouse)
4) Clear the Text property.
5) Now you can use the mouse to make the line as big (long/tall) as you need.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
... can anybody else actually understand most of what is written about C# in the MSDN Library? Or am I just stupid? lol
Jason.
j.t.
|
|
|
|
|
don't say that. you are not stupid.That is my mistake either.
it doesn't really help much. Searching in MSDN is a mistake.
.
.
.
.
Or maybe I'm stupid too.
|
|
|
|
|
Aw thanks Hot_ice lol I feel so much better now
Jason.
j.t.
|
|
|
|
|
I've never had any trouble understanding MSDN content. I'm no genius so draw your own conclusion...
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
yes.
most of it is understandable and informative, sometimes the examples are too simple or just missing.
and there are lots of pages explaining the concepts, but those are a tiny bit more difficult to locate.
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
|
|
|
|
|
Buy a book. The MSDN assumes a basic level of knowledge. Just like an encyclopedia assumes you know English.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Thanks Christian, I've always enjoyed reading your answers. Are there any books that you'd remcommend?
j.t.
|
|
|
|
|
0) You're stupid.
1) MSDN sucks, so that makes you stupid twice - first, because you're using MSDN, and second, because you don't understand what they've written (what little help they provide is written in clear English).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Hi All,
I have a doubt in C# XML update Operation.
while inserting/Updating/Deleting the node in XML ,I need to validate the xml with the corresponding Schema definition.Can you provide the solution without using the normal schema validation mechanism using C#.because every time while updating the node the normal validation mechanism takes more time for validating entire record.
|
|
|
|
|
|
Vista Style Button in C#[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
don't delete messages when they have been handled or are no longer relevant to you, it creates a messy forum. questions and replies can continue to be useful to others.
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
|
|
|
|
|
Sorry.I found there are some article in this site after I had wrote my post.
sepel
|
|
|
|
|
I think i have wrong GUID, how do i find out what GUID i should be using?
Im getting exception
Retrieving the COM class factory for component with CLSID {56A868B1-0AD4-11CE-B03A-0020AF0BA770} failed due to the following error: 80040154.
from following code
<code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Imapi2
{
[Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface IRawCDImageTrackInfo
{
void get_ISRC(
[Out,MarshalAs(UnmanagedType.BStr)] string value);
void get_StartingLba();
void get_SectorCount();
void get_TrackNumber();
void get_SectorType();
void put_ISRC();
void get_DigitalAudioCopySetting();
void put_DigitalAudioCopySetting();
void get_AudioHasPreemphasis();
void put_AudioHasPreemphasis();
void get_TrackIndexes();
}
[ComImport, Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770")]
class ccIRawCDImageTrackInfo
{
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
Imapi2.ccIRawCDImageTrackInfo ccTest1 =
new Imapi2.ccIRawCDImageTrackInfo();
Imapi2.IRawCDImageTrackInfo test1 =
(Imapi2.IRawCDImageTrackInfo)ccTest1;
}
catch (Exception ex)
{
Console.WriteLine("Unexpected COM exception: " + ex.Message);
}
Wait for completion.
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
}
}
</code>
http://msdn.microsoft.com/en-us/library/cc512151(VS.85).aspx[^]
That is link to interface i am trying to use
|
|
|
|
|
I was wondering if there was a better way of doing this?
What I am trying to accomplish is always checking for updates and displaying there is an update with a NotifyIcon. Now I got it working good, but was wondering if there was a better way.
The way I did it was used a timer (every 5 min). On the Tick event:
private void timerCheckUpdates_Tick(object sender, EventArgs e)
{
if (ApplicationDeployment.IsNetworkDeployed)
{
if (!CheckUpdate)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
try
{
ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted);
ad.CheckForUpdateAsync();
CheckUpdate = true;
}
catch (COMException)
{
ad.CheckForUpdateAsyncCancel();
}
}
}
}
void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
{
CheckUpdate = false;
if (e.UpdateAvailable)
{
notifyIcon1.ShowBalloonTip(5000, "Update Available!", "There is a new update available for this application!\nPlease click on the Help menu and click Check for updates.", ToolTipIcon.Info);
timerCheckUpdates.Enabled = false;
}
}
Ok I haven't tried it since I've changed it to the COMException, but if the user didn't have internet at all it would throw an exception. I am trying to get away from the error messages.
Is there a better way of doing this?
|
|
|
|