|
Just tried .NET Framework 2.0 on a different machine. TextRenderer does it's job, thanks for your advice. Although the result is not that precise (same with MeasureString(...)) - I might provide my own method to measure strings. Anyway, I'll let you know!
Cheers.
|
|
|
|
|
Hi,
I have got the AppBar code running in a project sucessfully but the bar is always anchored to the top of my screen - I would like to have a button that will anchor the AppBar to the bottom of my screen on the taskbar.
I've been looking at the code and i'm not exactly sure what I have to change to make the AppBar locate to the bottom of the screen.
I was wondering if it was this section?
// Move and size the appbar so that it conforms to the
// bounding rectangle passed to the system.
MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true);
Is there any chance someone could help me or point me in the correct direction on how I can do this?
Many Thanks,
Al
|
|
|
|
|
Hi all
I’ve created a simple windows service and successfully installed it using installutil.exe (.NET Framework 2.0 version). I want the service to run under the Local System account. When I attempt to start the service in SCM I get “Could not start the ATS Application Monitor service on Local Computer. Error 5: Access is denied” (where ATS Application Monitor is the name of the service). If I go to the Log On tab of the service properties dialog and change the logon account to my current user logon (which has full admin rights) I can then start the service.
The Startup Type to Automatic. I tried rebooting the machine in hopes that it would start before user account login.
The service was developed under Visual Studio 5 using the Windows Service template wizard but I built the installer class from the example code I was working from (Recipe 14.7 of Visual C# 2005 Recipes: A Problem-Solution Approach).
Thanks Leyla:
|
|
|
|
|
How to read and write in Notepad (.txt files).
Thanks.
Vasildb
|
|
|
|
|
Grab the mouse in your preferred mouse hand.
Move the cursor (white arrow thingy) towards the bottom left corner of the screen.
Click the "Start" button
Click the "Run" menu
Type in "Notepad"
Click OK
Click File | Open
Open the required file
Edit the file
Click File | Save
Click File | Exit
As of how to accomplish this, have you ever tried Google? Failing that try
|
|
|
|
|
|
The cat ate my mouse! What should I do now?
only two letters away from being an asset
|
|
|
|
|
Ah, now that's a problem. It's much too complicated for exceptional people to understand.
The hardest solution would be to use the keyboard (by pressing wierd combinations).
The simplest solution would be to go out and buy another computer with an RS232 port, setup a serial mouse and then using scripts in Hyperterminal or a similar program to provide the necessary signals to move the mouse.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Just plug the cat into your computer. If your cat is plug'n'pray compatible, you should get a cat pointer instead of the mouse pointer, but it works the same.
---
b { font-weight: normal; }
|
|
|
|
|
To my understanding, you meant, "How to read and write .TXT file". If so,
// READ
string readContent = System.IO.File.ReadAllText(string fileName) // .txt File name.
//WRITE
System.IO.File.WriteAllText(string fileName, string contentToWrite)
/******* PLEASE check the spelling and verify before using this snippet as I typed here whatever I remember. *****/
|
|
|
|
|
Is there a way to take a array of bytes and run those bytes as a program without saving them to any type of disk, only run those bytes form memory?
|
|
|
|
|
Yes
As of how to accomplish this, have you ever tried Google? Failing that try
|
|
|
|
|
EscKey2004 wrote: d run those bytes as a progr
Are those array of bytes a .NET program? If so, yes, you can run them from memory using System.Reflection.Assembly.Load
|
|
|
|
|
I have tried this I built a little test app that looks like this but I really did not get much of a response from the stuff I tried loading is there something I am doing wrong?
OpenFileDialog open = new OpenFileDialog();<br />
if (open.ShowDialog() == DialogResult.OK)<br />
{<br />
System.IO.FileStream st = new System.IO.FileStream(open.FileName.ToString(), System.IO.FileMode.Open);<br />
System.IO.BinaryReader br = new System.IO.BinaryReader(st);<br />
byte[] bytes = new byte[br.BaseStream.Length];<br />
br.Read(bytes, 0, bytes.Length);<br />
<br />
System.Reflection.Assembly a = System.Reflection.Assembly.Load(bytes);<br />
a.CreateInstance(a.GetType().ToString());<br />
}
|
|
|
|
|
Are you getting some exception with that code? What exactly doesn't work?
|
|
|
|
|
On some things I get a exception that looks like this, but then on some things it just dosent do anything.
"Could not load file or assembly '1453384 bytes loaded from asmTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
|
|
|
|
|
i just started a socket application that recieves UDP data. The data that i am recieving is a netflow packet from cisco devices. to learn how to do this i have been searching the forums and looking at other people's code for reference. some code that i came across was the following. pretty much what you do is, passed a byte[2048] to the procedure ToUInt and specify the starting point to get the datafield in the byte and the length from that starting position to get. the first field in the packet is the version field which starts at position 0 and is 16 bits long. so you would end up passing to the following code the byte[2048] of your data buffer, 0 for your offset and 16 for your length. i understand mostly all of the code except that part there the Shift Right occurs and the ANDing against 0x0001.
b is 10, and then after the bitwise operations is it 5. which is the correct version number for the netflow packet that my application recieved.
public static uint ToUInt(byte[] datagram, int offset, int length) {
uint total = 0;
int byte_index;
int bit_offset;
int bit;
byte b;
for ( int i = 0; i < length; i++ ) {
bit_offset = (offset+i) % 8;
byte_index = (offset+i-bit_offset) / 8;
b = datagram[byte_index];
bit = (int)(b >> (7 - bit_offset));
bit = bit & 0x0001;
if ( bit > 0 ) {
total += (uint)Math.Pow(2,length-i-1);
}
}
return total;
}
i modified the code to print to a console the values of each variable during each iteration of the loop. here are the values.
i bit_offset byte_index b bit total
0 0 0 0 0 0
1 1 0 0 0 0
2 2 0 0 0 0
3 3 0 0 0 0
4 4 0 0 0 0
5 5 0 0 0 0
6 6 0 0 0 0
7 7 0 0 0 0
8 0 1 5 0 0
9 1 1 5 0 0
10 2 1 5 0 0
11 3 1 5 0 0
12 4 1 5 0 0
13 5 1 5 1 4
14 6 1 5 0 4
15 7 1 5 0 5
i relize that the byte_index is just a counter for how many bits you have iterated through. once you went through 8 bits, incriment the byte index by 1. since the length is 16, that is two bytes and that would account for 0, and 1. i is just the counter set to the length of 16. i don't understand the B, bit, and total values. could someone explain the logic behind this to me?
|
|
|
|
|
I have added comments to part of the code:
bit_offset = (offset+i) % 8;<br />
<br />
byte_index = (offset+i-bit_offset) / 8;<br />
<br />
b = datagram[byte_index];<br />
<br />
bit = (int)(b >> (7 - bit_offset));<br />
<br />
bit = bit & 0x0001;<br />
<br />
total += (uint)Math.Pow(2,length-i-1);<br />
---
b { font-weight: normal; }
|
|
|
|
|
hey thanks a lot. this is helpful
|
|
|
|
|
Hi,
I am using VB Script by calling the script as a shell execution. Diagnostic.Process.Start(....)
But unofrtunately, the Process's EXITED event is not being fired ever. Looks like, the process is never being ended. Is there any reason why.
moreover, do I need to ship any pre requisite software to run VB Script along with my C# application to my client's Computer ?
|
|
|
|
|
Hello
bashiwala wrote: I am using VB Script by calling the script as a shell execution. Diagnostic.Process.Start(....)
I don't have that experience with VBScript. What's the extension of the file of your script, and what program that actually excutes the code?
bashiwala wrote: But unofrtunately, the Process's EXITED event is not being fired ever
Well that means that the program didn't ended at all. It's up to the code that you wrote in that VBScript to end itself or go into an empty loop for example.
bashiwala wrote: do I need to ship any pre requisite software to run VB Script along with my C# application to my client's Computer ?
AFAIK scripting languages don't produce stand alone exe files. scripts like VB need to be excuted inside another program -eg. Access, excel, etc..-. What exactly does your script do? and what program excutes it?
Regards
|
|
|
|
|
Thanks for your reply.
My VB SCRIPT is being used to convert an HTML file to a MS Word file. the extension is .VBS and I found that, in Windows, if I double click the .VBS file, the file is being executed as if it were an .EXE file. So I am using Process.Start to run the VB Script within C# application. I did not find any easy free library in C# to convert from HTML to MS Word but I found a very small cute snipped in VB Script to do that and in fact the VB Script is working fine in my Windows XP. But I am not sure if I ship this script to my client's PC would that work in the same way or not.
I dont have good knowledge on VBScript, in fact I hate this VB language (sorry if I offended VB programmers.., I did not mean that) but I found good snippets in VBScript for doing so many works fast.
Regards,
|
|
|
|
|
Hello
VBS files are opened using Windows Sripting srvice "C:\WINDOWS\System32\WScript.exe" file. It should be available in any windows edition. you can try to port it with your app, but I don't really recommend it.
About converting HTML to ms word, did you look into Office interop? Maybe there is something there.
About testing your apps, that brings me to Microsoft Virtual PC. You can download it for free via this link[^]. It enables you to install several windowses -XP pro, XP home, Me, etc...- inside yours, so that you could have a good idea on how your program would run on other pcs. Try it!
I hope that works for you! Good luck!
Regards
|
|
|
|
|
Hello,
In my Win application (C#)
- I use dataset designer to design data tables.
- I am using SQL Server Everywhere 2005.
I want to store the connection string within the CODE as a string variable, instead of App.Config file. (In order to hide database password) and I want that, when the application is loaded, the data source connection string is retrieved from the Code instead of App.Config.
Is it possible ? if so, would anyone please show me the way.
- My code is protected as I am using Obsfucator, so keeping password in String is not a problem.
Thanks and regards,
|
|
|
|
|
Hello
It's possible, yet it's a very BAD practice to hardcode your passwords in your exe file. A good practice is to store the password encrypted in an external config file -whatever it's-, then decrypt it in the code. Well, still breakable, but much harder than giving your password hardcoded on a silver plate to the disassembler.
Regards
|
|
|
|