|
This may or may not be the cause of your problem - there's way too much code there to plough through to be sure...
In your DoWork handler your creating a local variable strContainer and not using the global one
string strContainer = (string)ar[0]; If you meant to use the global one just drop the string at the start
strContainer = (string)ar[0];
|
|
|
|
|
Hi Dave.
That's exactly what happened. When I removed the 'string', it displayed correctly. Very strange.
Sorry for the huge posting everyone.
Have a great day,
WHEELS
|
|
|
|
|
Cool glad you've got it sorted.
Don't forget to aquire a lock on it as you're in a different thread in the DoWork handler, if it were accessed/modified from two threads at once you would have problems!
|
|
|
|
|
Hi,
Have you tried "Find All References" on the strContainer field. I haven't managed to read all of your code snippet(!) but I think you will find it is unassigned.
The btnSubmit_Click method declares a local variable strContainer, probably not what you meant to do.
Alan.
|
|
|
|
|
When trying to find the solution to a problem such as this I often set up a quickie test project with all the irrelevant stuff removed such as...
using System.ComponentModel;
using System.Windows.Forms;
namespace TestBGW
{
public partial class Form1 : Form
{
private BackgroundWorker backgroundWorker;
private string testString;
public Form1()
{
InitializeComponent();
backgroundWorker = new BackgroundWorker();
backgroundWorker.WorkerReportsProgress = true;
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
testString = "A";
backgroundWorker.RunWorkerAsync(testString);
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
string passedThrough = (string)e.Argument;
passedThrough = "B";
backgroundWorker.ReportProgress(0, passedThrough);
}
void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
MessageBox.Show(string.Format("{0} - {1}", testString, e.UserState));
}
}
} By the way, if you are accessing values that are not local to the DoWork handler inside it, you should aquire a lock on them first
|
|
|
|
|
Although I have all datatable columns set to accept DBNull, my application throws this exception:
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public System.DateTime ArrangementDate {
get {
try {
return ((global::System.DateTime)(this[this.tablePaymentArrangements.ArrangementDateColumn]));
}
catch (global::System.InvalidCastException e) {
throw new global::System.Data.StrongTypingException("The value for column \'ArrangementDate\' in table \'PaymentArrangements\' is DBNull.", e);
}
}
set {
this[this.tablePaymentArrangements.ArrangementDateColumn] = value;
}
}
I'm stumped (right now). Any pointers would be much appreciated please.
|
|
|
|
|
Hi,
I think DBNull is not compatible with DateTime . You should check if it is DBNull.Value and then send null back.
greetz
|
|
|
|
|
If that is a strongly typed dataset, you'll find it has an bool IsArrangementDateNull() method. You should use this to check before trying to read the value.
The reason for this is there is no way to cast DBNull.value to a DateTime.
|
|
|
|
|
DateTime is not nullable.
|
|
|
|
|
Hi all,
I have a bunch of H264 files with corrupt video profiles (showing a level of 20!) which means they dont work in Windows 7 or on my Xbox 360
I've fixed a few files by opening them up in a hex editor and searching for
61 76 63 43 01 4D 00 C8 FF E1 00 13 67 4D 00 C8
(note the 4D 00 C8 is the profile and level [C8 being the corrupt level])
and I replace this string with
61 76 63 43 01 4D 00 20 FF E1 00 13 67 4D 00 20
[changing the occurrence of C8 to 20 to make the level 3.2]
I have about 300 more mp4 files to do and I dont want to do them by hand, so is there an easy way I can read this in to c# and make the find and replace, then output the file again?
I know I can use things like streamreaders/writers and binary readers/writers, but if someone could offer some simple code on how to do it then it saves me asking bit by bit questions on how to do it
Thanks
|
|
|
|
|
Just sample...
const string SOURCE = @"D:\myFile.bin";
const string TARGET = @"D:\myNewFile.bin";
const string TOSEARCH = "4D-00-C8";
const string REPLACEWITH = "4D-00-20";
byte[] byteArray = File.ReadAllBytes(SOURCE);
string byteString = BitConverter.ToString(byteArray);
if (byteString.Contains(TOSEARCH))
{
string newByteString = byteString.Replace(TOSEARCH, REPLACEWITH);
string[] newByteStringSplitted = newByteString.Split('-');
byte[] newByteArray = new byte[newByteStringSplitted.Length];
for (int i = 0; i < newByteArray.Length; i++ )
{
newByteArray[i] = byte.Parse(newByteStringSplitted[i], NumberStyles.HexNumber);
}
File.WriteAllBytes(TARGET, newByteArray);
}
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using System.Reflection;
namespace testtesttestExcel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Declare these two variables globally so you can access them from both
//Button1 and Button2.
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;
Microsoft.Office.Interop.Excel.Workbooks objBooks;
Microsoft.Office.Interop.Excel.Sheets objSheets;
Microsoft.Office.Interop.Excel._Worksheet objSheet;
Microsoft.Office.Interop.Excel.Range range;
private void button1_Click(object sender, System.EventArgs e)
{
try
{
// Instantiate Excel and start a new workbook.
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Add(Missing.Value);
objSheets = objBook.Worksheets;
objSheet = (Microsoft.Office.Interop.Excel._Worksheet)objSheets.get_Item(1);
//Get the range where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
range = objSheet.get_Range("A1", Missing.Value);
range = range.get_Resize(5, 5);
//Create an array.
double[,] saRet = new double[5, 5];
//Fill the array.
for (long iRow = 0; iRow < 5; iRow++)
{
for (long iCol = 0; iCol < 5; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = iRow * iCol * iCol;
}
}
//Set the range value to the array.
range.set_Value(Missing.Value, saRet);
objApp.Visible = true;
objApp.UserControl = true;
}
catch( Exception theException )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, theException.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, theException.Source );
MessageBox.Show( errorMessage, "Error" );
}
Microsoft.Office.Interop.Excel.Range currentFind = null;
Microsoft.Office.Interop.Excel.Range firstFind = null;
string A = "16";
// You should specify all these parameters every time you call this method,
// since they can be overridden in the user interface.
currentFind = objSheet.Cells.Find(A, Type.Missing,
Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues, Microsoft.Office.Interop.Excel.XlLookAt.xlWhole,
Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false,
Type.Missing, Type.Missing);
while (currentFind != null)
{
// Keep track of the first range you find.
if (firstFind == null)
{
firstFind = currentFind;
//textBox1.Text = currentFind.get_Address(true, true, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, false, Missing.Value);
}
// If you didn't move to a new range, you are done.
else if (currentFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing)
== firstFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing))
{
break;
}
currentFind.Font.Color = System.Drawing.ColorTranslator.ToOl
(System.Drawing.Color.Red);
currentFind.Font.Bold = true;
currentFind = objSheet.Cells.FindNext(currentFind);
}
}
}
After finding the cell containing "16", i want to write in string data to the right of it. how should i go about doin this. I did some research on the codes, but i kept getting errors. Please advise me on my problem. Thanks alot!!
modified on Friday, September 11, 2009 11:12 AM
|
|
|
|
|
i'm trying to obtain my hardware information through wmi
but i cant obtain ram manufacture
i think PNPdeviceid field in win32_physical memory must be useful
but its appirience is UPSET
please help me
|
|
|
|
|
Manufacturer property in Win32_PhysicalMemory will return that.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
i knew it
but that field returned no value
|
|
|
|
|
moein.serpico wrote: but that field returned no value
How many machines have you tried it on?
If only 1, have you found any application that does return a value for that machine?
It may be that on that particular machine, it is not defined.
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.”
|
|
|
|
|
yes
its name is everest
i download it from softpedia
please if you know some way
show me
thanks
|
|
|
|
|
Unfortunately I do not know another way.
It is just that I have one PC where the method suggested by d@nish works, and another where it doesn't.
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.”
|
|
|
|
|
|
|
There is nothing that says that a manufacturer of a component MUST supply the information for each field in WMI. There nothing commiting manufacturers to supporting WMI at all, so this is no surprise.
The data comes from the memory itself, probabyl though some port communication, not through WMI. I don't know how to get at it though.
|
|
|
|
|
I am developing an application to play DVD. however When i insert a disk, Windows will automatically try to open that disk either in an explorer window or ask the user what to do with the disk. Then I search in the internet and find two approaches.
The first and simplest is to register the special Windows message "QueryCancelAutoPlay" and simply return 1 when the message is handled. This only works for the current window, and not a background application.
The second approach requires inserting an object that implements the COM interface IQueryCancelAutoPlay COM interface into the Running Object Table.
I used the first one. But sometimes two messages of "QueryCancelAutoPlay" are received and the autoplay window appears again. Here is my code of cancel auto play. Sometimes one message of "QueryCancelAutoPlay" is received and the autoplay window doesn't appear. Sometimes no message of "QueryCancelAutoPlay" is received and the autoplay window appear again.
here is my code of cancel the autoplay window.
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (g_uQueryCancelAutoPlay == 0)
{
g_uQueryCancelAutoPlay = RegisterWindowMessage("QueryCancelAutoPlay");
}
if (g_uQueryCancelAutoPlay != 0 && (uint)msg == g_uQueryCancelAutoPlay)
{
System.Windows.MessageBox.Show("QueryCancelAutoPlay1"); //Sometime it appears twice, sometimes it doesn't appear
return (IntPtr)1;
}
return IntPtr.Zero;
}
|
|
|
|
|
|
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
|
|
|
|
|