|
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
|
|
|
|
|
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
|
|
|
|