|
|
Thank you. But I want to cancel auto play in my application.
modified on Sunday, September 13, 2009 9:14 PM
|
|
|
|
|
Hi
I'm trying to do a little application to monitor Network traffic and limit the global speed. It's something like NetLimiter.
So, until now, i managed to get all network interfaces and the information for each one(like download and upload speed, bytes send and received,...). I also have information about all network connections and windows processes.
Now, i don't know how to limit the max speed to a given network interface and how to know which process is using which connection.
I know this is not a very good explanation but my english is quite limited.
Thank's
|
|
|
|
|
I need to cast some byte arrays to structs. The solution I have come up with can be seen in the following example.
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct Reading
{
public float value;
public reading_info_struct info;
public override string ToString() {
return value.ToString();
}
#region Byte conversions
public unsafe byte[] ToBytes() {
byte[] arr = new byte[sizeof(Reading)];
fixed (byte* parr = arr) {
*((Reading*)parr) = this;
}
return arr;
}
public static unsafe Reading FromBytes(byte[] arr) {
if (arr.Length < sizeof(Reading))
throw new ArgumentException();
Reading s;
fixed (byte* parr = arr) {
s = *((Reading*)parr);
}
return s;
}
#endregion
}
Is there some less wicked way to do this? I have a lot of these structures and would like to avoid implementing the byte array conversion code in each of them.
In C/C++ this would be easy..
modified on Friday, September 11, 2009 5:55 AM
modified 12-Feb-22 21:01pm.
|
|
|
|
|
Hi,
1.
use PRE tags instead of CODE tags, they preserve formatting.
2.
have a look at the Marshal class, e.g. its PtrToStructure() method.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
That looks OK to me; the class should handle itself.
|
|
|
|
|
I'm currently using VS2005 Crystal report... I cant pass the parameter from Main report to its sub report.... it always encounter an error "@pParameter" value expected
I can successfully display a crystal report with parameters but it will fail when it involves subreports.... I don't understand also why I cant display the above parameter but i noticed it runs successfully because it will display the expected output...
hope to here some1 who can share thier ideas..
Thank you
below is the code:
string reportName = Session["ReportName"].ToString();
string reportDate = Session["ReportDate"].ToString();
string reportType = Session["ReportType"].ToString();
rpt.Load(Server.MapPath("~/Reports/" + reportName.ToString()));
crConnectionInfo.ServerName = Session["MyServer"].ToString();
crConnectionInfo.DatabaseName = Session["myDatabase"].ToString();
crConnectionInfo.UserID = "myUser";
crConnectionInfo.Password = "myPassword";
crDatabase = rpt.Database;
crTables = crDatabase.Tables;
CrystalReportViewer1.ReportSource = rpt;
ParameterDiscreteValue discreteBranch = new ParameterDiscreteValue();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteBranch = new ParameterDiscreteValue();
ParameterField paramFieldBranch = new ParameterField();
paramFieldBranch.Name = "@pBranchCode";
paramDiscreteBranch.Value = Session["branchCode"].ToString();
paramFieldBranch.CurrentValues.Add(paramDiscreteBranch);
paramFields.Add(paramFieldBranch);
ParameterDiscreteValue paramDiscreteTranDate = new ParameterDiscreteValue();
ParameterField paramFieldTranDate = new ParameterField();
paramFieldTranDate.Name = "@pTransactionDate";
paramDiscreteTranDate.Value = reportDate;
paramFieldTranDate.CurrentValues.Add(paramDiscreteTranDate);
paramFields.Add(paramFieldTranDate);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
discreteBranch.Value = Session["branchName"].ToString();
rpt.SetParameterValue("BranchName", discreteBranch);
discreteBranch.Value = Session["branchaddress"].ToString();
rpt.SetParameterValue("BranchAddress", discreteBranch);
xxx
|
|
|
|
|
hey body to get an answer first put ur code in a codeblock ......... so that other can see it well and give u a reply
|
|
|
|
|
I don't know f u read my post very well or u just don't understand.... i already put the entire code block in my post....
xxx
|
|
|
|
|
I am using Iexpress.exe to package all installation files(setup.exe,msi,.net framework etc) into single exe.
But the exe is not working.
I have created a batch file including following:
@ECHO OFF
CLS
MD dotnetfx
MOVE /-Y dotnetfx.exe dotnetfx
MOVE /-Y instmsia.ext dotnetfx
MOVE /-Y WindowsInstaller-KB893803-v2-x86.exe dotnetfx
EXIT
And selecting batch file,setup.exe and msi file in iexpress.exe for creating package.
Got the single exe but while installation i am getting:
This installation package could not be opened. Verify that the package exists and that you can access it or contact the application vendor to verify that this is a vlaid windows installer package.
And InstallLog file shows:
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [ProcessorArchitecture] = Intel {string}
Property: [VersionNT] = 6.0.1 {version}
Running checks for package '.NET Framework 2.0 (x86)', phase BuildList
Running external check with command 'C:\Users\user\AppData\Local\Temp\VSD12B7.tmp\DotNetFX\dotnetchk.exe' and parameters ''
Process exited with code 1
Setting value '1 {int}' for property 'DotNetInstalled'
Reading value 'Version' of registry key 'HKLM\Software\Microsoft\Internet Explorer'
Read string value '7.0.6001.18000'
Setting value '7.0.6001.18000 {string}' for property 'IEVersion'
The following properties have been set for package '.NET Framework 2.0 (x86)':
Property: [DotNetInstalled] = 1 {int}
Property: [IEVersion] = 7.0.6001.18000 {string}
Running checks for command 'DotNetFX\instmsia.exe'
Result of running operator 'ValueExists' on property 'VersionNT': true
Result of checks for command 'DotNetFX\instmsia.exe' is 'Bypass'
Running checks for command 'DotNetFX\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'ValueExists' on property 'Version9x': false
Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.0.3': false
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.0': true
Result of checks for command 'DotNetFX\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
Running checks for command 'DotNetFX\dotnetfx.exe'
Result of running operator 'ValueNotEqualTo' on property 'DotNetInstalled' and value '0': true
Result of checks for command 'DotNetFX\dotnetfx.exe' is 'Bypass'
'.NET Framework 2.0 (x86)' RunCheck result: No Install Needed
Running checks for package 'Windows Installer 3.1', phase BuildList
The following properties have been set for package 'Windows Installer 3.1':
Running checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.1': true
Result of checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
'Windows Installer 3.1' RunCheck result: No Install Needed
Launching Application.
Running command 'C:\Windows\system32\msiexec.exe' with arguments ' -I "C:\Users\user\AppData\Local\Temp\IXP000.TMP\tes.msi" '
Please give me clue where I am going wrong.
Thanks in Advance
Gtag.
|
|
|
|
|
I would investigate a thing called "Inno Setup" it is extremely good !
|
|
|
|
|
I'm currently doing SMS system with C#.
I have no idea how to retrieve a website(timetable) that requires an input. Anyone can help?
This is my code:
public string generateURL(string id)
{
string siteUri ="http://utptt-ex.petronas.com.my/studentInd.htm";
webrequest wr= webrequest.create(siteUri);
return wr;
}
But i have some bugs. Is there anyone who has better codes to this?
|
|
|
|
|
I think you might be trying this using HTTP over TCP/IP.. If so then you need to hit an uri with some parama..and retrieve the acknowledgment.
Try this link
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
Thanks
Md. Marufuzzaman
|
|
|
|
|
Follow the Following code. Pass the number to Download function in string format. You ll get the answer. Worked for me.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace RequestURL
{
class Program
{
static void Main(string[] args)
{
string response = Download("0");
Console.WriteLine(response);
Console.ReadLine();
}
private static string Download(string number)
{
string text = "http://utptt-ex.petronas.com.my/Reporting/Individual?identifier=" + number + "&B1=View+Timetable&objectclass=students&idtype=id&width=100&periods=1-30";
string responseFromServer = "";
try
{
WebRequest request = WebRequest.Create(text);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
responseFromServer = reader.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return responseFromServer;
}
}
}
|
|
|
|
|
Thank you for the codes, can I save the response from the web into a file?
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace RequestURL
{
class Program
{
static void Main(string[] args)
{
string response = Download("0");
Console.WriteLine(response);
Console.ReadLine();
}
private static string Download(string number)
{
string text = "http://utptt-ex.petronas.com.my/Reporting/Individual?identifier=" + number + "&B1=View+Timetable&objectclass=students&idtype=id&width=100&periods=1-30";
string responseFromServer = "";
try
{
WebRequest request = WebRequest.Create(text);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.ASCII);
responseFromServer = reader.ReadToEnd();
StreamWriter writer = new StreamWriter("C:\\a.txt");
writer.Write(responseFromServer);
writer.Close();
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return responseFromServer;
}
}
}
|
|
|
|
|
my english is pool. i don't know clearly.
for example:
public static string Post(string action, string parmString)
{
try
{
//Encode
Encoding myEncoding = Encoding.GetEncoding("GB2312");
//get URL
Uri myUri = new Uri(action);
//byte[]
byte[] paramBytes = myEncoding.GetBytes(parmString);
//new a webrequest
WebRequest myWebRequest = WebRequest .Create(myUri);
//set ContentType
myWebRequest.ContentType = "application/x-www-form-urlencoded";
//set Method
myWebRequest.Method = EnumWebMethod.POST.ToString();
//init request, get back stream
using (Stream requestStream = myWebRequest.GetRequestStream())
{
//send data
requestStream.Write(paramBytes, 0, paramBytes.Length);
}
//send request, get WebResponse object
WebResponse myWebResponse = myWebRequest.GetResponse();
//
using (StreamReader myStreamReader = new StreamReader(myWebResponse.GetResponseStream(), myEncoding))
{
return myStreamReader.ReadToEnd();
}
}
catch
{
return "request error!";
}
}
i hope i can help you.
modified on Wednesday, September 23, 2009 9:41 PM
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:04pm.
|
|
|
|
|
HI
I am developing a .NET MyLib.dll to be exposed via COM to Excel.
In It there is a class called MyDotNetClass ( ComVisible is set to ture
and I have GUID attributer )
When I pass a Range to my AnyMethod and I want to get the FormulaR1C1Local
everything is thine.
When I want to call other method other than this ( including the getValue to get
the real valu conatined by the cells in that range, not its formula )
I have a lot of exception most of the same time.
Can you help me with that?
I already have a reference to Microsoft.Office.Interop.Excel library V12.0
for Excel 2007.
Thanks
Mn
<br />
class MyDotNetClass<br />
{<br />
String AnyMethod( Microsoft.Office.Interop.Excel.Range aRange )<br />
{<br />
object[,] formula = (object[,])aRange.FormulaR1C1;<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
'VB CODE<br />
Function MyFoo( aRange As Range) As String<br />
Dim myLibObj As New MyLib<br />
MyFoo = myLibObj.AnyMethod( aRange )<br />
End Function<br />
|
|
|
|
|
Hi All,
I am creating one MDI application using C# in VS 2008. I attached the code below. I open one RTF file through the Open menu of the main form using Open dialog and loads the file in to the rich text box present in the child form. My problem is before loading the file in to the child form, the current directory points to the Debug folder of the application, but after loading the file in to the child form the current directory changes to the file directory which I opened in the child form.
For example,
before loading the file, my current directory is : "C:\Sample\Debug"
after loading the file, it changes to : "C:\ArchiveFiles"
because i opened a file from the "C:\ArchiveFiles" directory.
It is the intended behaviour of the MDI application. How do avoid changing the current directory? I want the current directoy should always point to the directory from where the EXE is running.
Is there any way to do this?
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
Form4 f4 = null;
public Form3()
{
InitializeComponent();
this.IsMdiContainer = true;
f4 = new Form4();
f4.MdiParent = this;
f4.Show();
string ctDir = System.Environment.CurrentDirectory;
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
if (DialogResult.OK == openFileDialog1.ShowDialog())
{
f4.OpenFile(openFileDialog1.FileName, this);
}
string ctDir = System.Environment.CurrentDirectory;
MessageBox.Show(ctDir);
}
}
}
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
public void OpenFile(string filename,Form parent)
{
richTextBox1.LoadFile(filename);
}
}
Thanks in advance,
Mutpan
|
|
|
|
|
Set the directory before showing the dialog.
mutpan wrote: Form4 f4 = null;
You're joking, right ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: mutpan wrote:
Form4 f4 = null;
You're joking, right ?
Good point!
|
|
|
|
|
i don't know why you want to get current Directory.
so you can try these.
1) you can use:
System.IO.Directory.GetCurrentDirectory();
AppDomain.CurrentDomain.BaseDirectory;
Application.StartupPath
AppDomain.CurrentDomain.SetupInformation.ApplicationBase
Application.ExecutablePath
and so on.
2)
you can save the CurrentDirectory Path to a string at the first time you get it .
and send to the other form when you open it.
modified on Wednesday, September 23, 2009 9:45 PM
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:05pm.
|
|
|
|
|
hello
i am using toolstripComboBox.i want to access all the System colour paterns Along with there name how can i do this
i achive this on Simple combo on the form but for toolstripcombo it will not work
|
|
|
|
|
For anyone to be able to help you, we need to know what 'it will not work' means.
Some code (not too much, and properly formatted, use PRE tags) with an indication of which part fails, any error messages etc.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hello
if i am using simple combo box on the form the Draw item event appear and i use code on this event is
private void cmbboxClr_DrawItem(object sender, DrawItemEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rect = e.Bounds;
if (e.Index >= 0)
{
string n = ((ComboBox)sender).Items[e.Index].ToString();
Font f = new Font("Arial", 9, FontStyle.Regular);
Color c = Color.FromName(n);
Brush b = new SolidBrush(c);
g.DrawString(n, f, Brushes.Black, rect.X, rect.Top);
g.FillRectangle(b, rect.X + 110, rect.Y + 5, rect.Width - 10, rect.Height - 10);
}
}
-----------------------------
and at form load event i use code
Type colorType = typeof(System.Drawing.Color);
PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
foreach (PropertyInfo c in propInfoList)
{
this.cmbboxClr.Items.Add(c.Name);
}
-------------------------------
and at select index change i use the code
private void cmbboxClr_SelectedIndexChanged(object sender, EventArgs e)
{
string color = this.cmbboxClr.SelectedItem.ToString();
this.panel1.BackColor = Color.FromName(color);
}
this will do but when i use toolstripcombo i'm not getting event Draw Item how can i achive the same thing using toolstripcombo my main problem is to access system colour patern along with name to change font or background colour
|
|
|
|