|
I'm trying to change the system date and time on XP Pro:
In the form's class header I have:
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetSystemTime( [In] ref structSystemTime st );
public struct structSystemTime
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
Then in Form_Load I have:
structSystemTime st = new structSystemTime ();
st.wYear = 2003;
st.wMonth = 5;
st.wDay = 22;
st.wHour = 22;
st.wMinute = 15;
st.wSecond = 08;
SetSystemTime(ref st);
It compiles and runs, but the date/time doesn't change. Anyone know what's wrong?
Everything Makes Sense In Someones Mind
|
|
|
|
|
KMAROIS wrote: It compiles and runs, but the date/time doesn't change. Anyone know what's wrong?
Change the definitions of the fields from short to ushort (unsigned short).
|
|
|
|
|
If fixing the structure doesn't help, does
GetLastWin32Error() return a useful error code?
if (!SetSystemTime(ref st))
{
int errcode = Marshal.GetLastWin32Error();
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I changed the struct and it did not work. It returned 1314, which is:
if (!SetSystemTime(ref st))
{
int errcode = Marshal.GetLastWin32Error();
string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
MessageBox.Show(errorMessage);
}
Turns out the Sys Admin has restricted users from chaning the date/time.
Now to go find the sys admin....
Everything Makes Sense In Someones Mind
|
|
|
|
|
There is usually a good reason, good luck with the Admin, take your flame proof suit!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Whenever I use WinAPI, the equivelant of any integer (short or int) in API documentation, I always have to use Int32.
Regards,
Thomas Stockwell
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.
Visit my Blog
|
|
|
|
|
I have the same problem but the marshal tells me that error 57
Have you managed to solve it?
|
|
|
|
|
How can i mask "Internet IP Address" with "C#"
|
|
|
|
|
maliaslam wrote: How can i mask "Internet IP Address" with "C#"
Before you get an answer to this question, you're going to have to do some serious convincing that this is for a legitimate purpose. Why do you need to do this?
|
|
|
|
|
maliaslam wrote: Internet IP Address
Internet Internet Protocol Address
As he said earlier, why do you need this?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: Internet Internet Protocol Address
It's to differentiate this from baked bean tin IP address.
|
|
|
|
|
I make "annonymose web browser" so please tell me how to do this
|
|
|
|
|
|
Hi,
How do you build a project of multiple classes and resources using the CSC program from the command line?
Many thanks!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
csc /?
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
Visual C# 2008 Compiler Options
- OUTPUT FILES -
/out:<file> Specify output file name (default: base name of file with main class or first file)
/target:exe Build a console executable (default) (Short form: /t:exe)
/target:winexe Build a Windows executable (Short form: /t:winexe)
/target:library Build a library (Short form: /t:library)
/target:module Build a module that can be added to another assembly (Short form: /t:module)
/delaysign[+|-] Delay-sign the assembly using only the public portion of the strong name key
/doc:<file> XML Documentation file to generate
/keyfile:<file> Specify a strong name key file
/keycontainer:<string> Specify a strong name key container
/platform:<string> Limit which platforms this code can run on: x86, Itanium, x64, or anycpu. The default is anycpu.
- INPUT FILES -
/recurse:<wildcard> Include all files in the current directory and subdirectories according to the wildcard specifications
/reference:<alias>=<file> Reference metadata from the specified assembly file using the given alias (Short form: /r)
/reference:<file list> Reference metadata from the specified assembly files (Short form: /r)
/addmodule:<file list> Link the specified modules into this assembly
- RESOURCES -
/win32res:<file> Specify a Win32 resource file (.res)
/win32icon:<file> Use this icon for the output
/win32manifest:<file> Specify a Win32 manifest file (.xml)
/nowin32manifest Do not include the default Win32 manifest
/resource:<resinfo> Embed the specified resource (Short form: /res)
/linkresource:<resinfo> Link the specified resource to this assembly (Short form: /linkres)
Where the resinfo format is <file>[,<string name>[,public|private]]
- CODE GENERATION -
/debug[+|-] Emit debugging information
/debug:{full|pdbonly} Specify debugging type ('full' is default, and enables attaching a debugger to a running program)
/optimize[+|-] Enable optimizations (Short form: /o)
- ERRORS AND WARNINGS -
/warnaserror[+|-] Report all warnings as errors
/warnaserror[+|-]:<warn list> Report specific warnings as errors
/warn:<n> Set warning level (0-4) (Short form: /w)
/nowarn:<warn list> Disable specific warning messages
- LANGUAGE -
/checked[+|-] Generate overflow checks
/unsafe[+|-] Allow 'unsafe' code
/define:<symbol list> Define conditional compilation symbol(s) (Short form: /d)
/langversion:<string> Specify language version mode: ISO-1, ISO-2, or Default
- MISCELLANEOUS -
@<file> Read response file for more options
/help Display this usage message (Short form: /?)
/nologo Suppress compiler copyright message
/noconfig Do not auto include CSC.RSP file
- ADVANCED -
/baseaddress:<address> Base address for the library to be built
/bugreport:<file> Create a 'Bug Report' file
/codepage:<n> Specify the codepage to use when opening source files
/utf8output Output compiler messages in UTF-8 encoding
/main:<type> Specify the type that contains the entry point (ignore all other possible entry points) (Short form: /m)
/fullpaths Compiler generates fully qualified paths
/filealign:<n> Specify the alignment used for output file sections
/pdb:<file> Specify debug information file name (default: output file name with .pdb extension)
/nostdlib[+|-] Do not reference standard library (mscorlib.dll)
/lib:<file list> Specify additional directories to search in for references
/errorreport:<string> Specify how to handle internal compiler errors: prompt, send, queue, or none. The default is queue.
/moduleassemblyname:<string> Name of the assembly which this module will be a part of
|
|
|
|
|
Hi Guys,
I am wondering if it is possible to search all the computers within a domain or a network to discover all the excel files and then store them in a common location?
I have seen some examples of searching computers in a domain but didn't find any example for file search in a domain.
Can somebody help please?
Thanks
happy coding!
|
|
|
|
|
Why on earth would you do that instead of letting the user decide what should be commonly accessed and what shouldn't be?
|
|
|
|
|
I can see an admin requirement for this but I don't think you are going to achieve it. You need at least read only access to EVERY folder on the network. I imagine if you own the network you could do this, IBM has a tool to check the files on a PC but they turn up with a USB key to do it and I'm pretty bloody sure they would rather do it centrally .
There are a number of enterprise tools out there which require you to register a sheet and it stores it in a database and uses version control and change management on the REGISTERED files only. Serious enterprise money though.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It sounds like what you are looking for is an entrprise search server. It won't let you change where the files are stored, but it will index the locations of the files on your network and allow people to search for files.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Hi Everyone,
I'm learning C# and am stuck on writing code for a calculation.
Here's the parameters:
Calculate and display the price.
The calculations will require price per hour.
My project has the customer name input, item rented input x the # of hours rented = total cost. Pressing the calculate button will perform this function.
Any help here would be appreciated.
Thanks
jeff
|
|
|
|
|
Sounds like a homework assignment, so here are only some hints:
Create a textbox for the price and a textbox for the # of hours (a NumericUpDown control may be better for the latter, no string-to-number conversion required there).
Create a button clicked event handler for the calculate button and do the calculation there.
You can convert from the textbox string to decimal/integer via Decimal.TryParse[^] or Int32.TryParse[^] method, respectively.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Sounds like a homework assignment
His post down further in the thread really make me suspicious, it sounds like a problem I use in my class, and the funny thing is, my class doesn't start for a few more weeks.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
fratboy trying to repair damage to the cheat library before school restarts because a helpful student cleaner tossed them all over the summer?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Yep. Like I just told Guffa, my very similar problem is usually assigned about mid-October for the Fall term. People may look to the assistance of my former students are going to be in for a rude surprise. After about 2 years of teaching this class, I am doing a complete overhaul of it
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
So... the schools have started again...
The calculation part of the code is very easy:
price = pricePerHour * hours;
So, is that really where your problem lies?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|