|
Straight from msn:
NTSTATUS status;
status = WdfUsbTargetDeviceResetPortSynchronously(UsbDevice);
And please don't use the 'urgent!!' word inside the title, read the rules ...
|
|
|
|
|
sry about the urgent thing
anyway what is NTSTATUS ? is it a class or something ? ( i never used com and win32 stuff)
thx a lot for your time
|
|
|
|
|
Why do you ask these kind of questions to us?
The internet is like a very big book. To find some stuff in the book you can either ask people who have read it or you scan the text. For the big book called 'the internet' there are many full automatic scanners available (google.com for instance). If you have found a piece of usefull information, you should read the piece... if you'd done that, you wouldn't be asking questions.
http://msdn.microsoft.com/en-us/library/aa489609.aspx[^]
|
|
|
|
|
well i did lot of searches but no results :s
|
|
|
|
|
C# doesn't have functions.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: C# doesn't have functions
yh i know plz read the question before you answer
|
|
|
|
|
Hello,
Can you reduce the resolution of a PDF, for example I have a pdf with a size greater than A4 is I ve go to the A4, is that possible?
Thank you very much.
|
|
|
|
|
You posted this question in much more detail four posts down and two hours ago. We do not consider it polite to repost questions.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
i have a code below, it can run but didn't work actually. can you help me?
here is my process:
Start Recording-> Stop Recording-> Play sound: nothing happened -> Play Sound (second): error at line
'this.captureBuffer.Read(0, this.stream, 100000, LockFlag.None);'
(Memory stream is not expandable.)
code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using Microsoft.DirectX.DirectSound;
using Buffer = Microsoft.DirectX.DirectSound.Buffer;
namespace Sound
{
public class Sound : System.Windows.Forms.Form
{
// private fields
private Device device;
private Capture capture;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private Buffer buffer;
private BufferDescription bufferDesc;
private CaptureBuffer captureBuffer;
private WaveFormat waveFormat;
private CaptureBufferDescription captureBuffDesc;
private MemoryStream stream;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private byte[] streamBuffer;
public Sound()
{
InitializeComponent();
// Set up DirectSound
CreateDevice();
// Load the sound
CreateWaveFormat();
CreateBufferDescription();
CreateBuffer();
// Set the cooperative level
SetCooperativeLevel();
CreateCapture();
CreateCapureDescription();
CreateCaptureBuffer();
CreateStreamBuffer();
CreateStream();
}
private void CreateDevice()
{
device = new Device();
}
private void CreateBuffer()
{
buffer = new Buffer(bufferDesc, this.device);
}
private void CreateBufferDescription()
{
bufferDesc = new BufferDescription();
bufferDesc.Format = waveFormat;
bufferDesc.BufferBytes = 100000;
bufferDesc.ControlPositionNotify = true;
bufferDesc.ControlFrequency = true;
bufferDesc.ControlPan = true;
bufferDesc.ControlVolume = true;
}
private void SetCooperativeLevel()
{
device.SetCooperativeLevel(
this, // The window for the application
CooperativeLevel.Priority // The cooperative level
);
}
private void CreateWaveFormat()
{
waveFormat = new WaveFormat();
waveFormat.BitsPerSample = 8;
waveFormat.BlockAlign = 1;
waveFormat.Channels = 1;
waveFormat.AverageBytesPerSecond = 20500;
waveFormat.SamplesPerSecond = 20500;
waveFormat.FormatTag = WaveFormatTag.Pcm;
}
private void CreateCapture()
{
capture = new Capture();
}
private void CreateCapureDescription()
{
captureBuffDesc = new CaptureBufferDescription();
captureBuffDesc.BufferBytes = 100000;
captureBuffDesc.Format = this.waveFormat;
}
private void CreateCaptureBuffer()
{
captureBuffer = new CaptureBuffer(captureBuffDesc, capture);
}
private void CreateStream()
{
stream = new MemoryStream(streamBuffer);
}
private void CreateStreamBuffer()
{
streamBuffer = new byte[100000];
for (int i = 0; i < 100000; i++)
streamBuffer[i] = 0;
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(208, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Play Sound";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(48, 72);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(208, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Stop Sound";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(48, 136);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(208, 23);
this.button3.TabIndex = 2;
this.button3.Text = "Start Recording";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(48, 176);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(208, 23);
this.button4.TabIndex = 3;
this.button4.Text = "Stop Recording";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// Game
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Sound";
this.Text = "Sound";
this.ResumeLayout(false);
}
#endregion
public static void AS()
{
Sound s = new Sound();
s.Show();
Application.Run(s);
}
private void button1_Click(object sender, System.EventArgs e)
{
this.captureBuffer.Read(0, this.stream, 100000, LockFlag.None);
buffer.Write(0, this.stream, (int)this.stream.Length, LockFlag.EntireBuffer);
buffer.Play(0, BufferPlayFlags.Looping);
}
private void button2_Click(object sender, System.EventArgs e)
{
buffer.Stop();
}
private void button3_Click(object sender, System.EventArgs e)
{
this.captureBuffer.Start(true);
}
private void button4_Click(object sender, System.EventArgs e)
{
this.captureBuffer.Stop();
}
}
}
modified on Friday, February 27, 2009 10:00 AM
|
|
|
|
|
No...
1. post code in the pre tags
2. post a question we can and WOULD LIKE to anwser
3. be more specific (maybe show the error?)
|
|
|
|
|
Do people expect 300+ lines of code to be debugged for free just because they posted it..?
|
|
|
|
|
How else do you think they can offer $15/hour "consulting" fees on places like RentACoder?
|
|
|
|
|
Hello everyone,
If the app.config format is wrong, for example, not a correct format XML file, application will fail from loading. Are there any ways to let me know such issue -- for example, receiving some events (so that I could write file log and event log to record this issue) if app.config loads error because of a mal-formatted XML file?
thanks in advance,
George
|
|
|
|
|
You could try to subscribe to the System.AppDomain.UnhandledException event, see if you can intercept the app.config error.
|
|
|
|
|
Thanks Mirko1980!
My code and app.config looks like this, but no exception is thrown. Any ideas?
class Program
{
public static void MyEventHandler(object sender, EventArgs e)
{
return;
}
static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += MyEventHandler;
return;
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configuration>
regards,
George
|
|
|
|
|
Hi,
Code like this will catch the exception which occurs when the form is created.
Alan.
try {
CsTermForm mainForm = new CsTermForm();
Application.Run(mainForm);
} catch (System.Configuration.ConfigurationException ce) {
MessageBox.Show(ce.ToString());
}
|
|
|
|
|
Hi Alan!
Your code works ok in a Windows forms application. But for a console application, how to handle?
regards,
George
|
|
|
|
|
Hi,
Pretty much the same really. You just have to wrap any code that may access the settings in an exception block.
I've just trashed one of my config files and the following code trapped the exception.
static Int32 Main(string[] args) {
try {
App app = new App();
Int32 exitcode = app.Run();
return exitcode;
} catch (System.Configuration.ConfigurationException ce) {
Console.WriteLine(ce);
return 1;
}
}
|
|
|
|
|
Hi Alan,
I am writing a DLL, could I handle such issue inside the DLL?
regards,
George
|
|
|
|
|
George,
George_George wrote: could I handle such issue inside the DLL?
That I don't know. I've only ever used a top level handler designed to just stop the application dead in it's tracks if the config file is corrupted. If the exception occurs within the dll it will of course be passed up the call stack until a handler is found.
One thing to note is that changes to the dll's user scoped configuration settings are stored in the exe's user.config file so I suspect the best place to trap any exceptions caused by malformed xml is very early in the execution of the application.
Anything more precise than that is beyond my current level of knowledge. I had a quick look at the System.Configuration namespace and decided I wouldn't go back there again unless I absolutely had to!
Alan.
|
|
|
|
|
Thanks Alan,
1.
I can put the exception handling to EXE level. But it is still different from your posted solution before -- you use a starter EXE to track the actual configuraiton issues in the inner EXE, correct?
2.
So, do you have any ideas to let the EXE itself handle the app.config issue?
3.
If you do not suggest to handle such issue, what is your point and any advice to let end user know such issues (because of configuration file format error)?
regards,
George
|
|
|
|
|
Hi All,
I have a base class (Day) and collection class (Days) and I want to inherit from them both:
public class Day
{
Members…
}
public class Days : List<Day>
{
Methods…
}
To inherit from the Day class is straight forward
public class SpecialistDay : Day
{
Specialist Members…
}
The question is, can I inherit the members from SpecialistDay and the methods from Days with a SpecialistDays collection class?
Many thanks
Janet
Lady Programmers are a rare breed!
|
|
|
|
|
Hi,
this is how I understand it:
- you can create a special list of Days, with class SpecialDays1 : Days, but then the items have type Day
- you can create a list of SpecialDays, with class SpecialDays2 : List(SpecialDays), but then you don't inherit from Days.
However if you want a special list of special days, then you should inherit from a generic special list. You could achieve that like so (you may want to restrict T below):
public class DayList< T> : List< T> {}
public class SpecialDayList< T> : DayList< T> { ... }
public class Day { }
public class SpecialDay : Day { ... }
public class Days : DayList< Day> { }
public class SpecialListOfSpecialDays : SpecialDayList< SpecialDay>
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, February 27, 2009 9:04 AM
|
|
|
|
|
Yeah, that sounds about right. Maybe add where clauses to the lists.
|
|
|
|
|
If you're asking about multiple inheritance, that is, a class SpecialistDays that inherits from both SpecialistDay and Days, then, unfortunately, you can't do that in .NET. This could also lead to the Fragile Base Class[^] problem if your base classes change a lot; this problem lead to the famous article Why extends is evil[^], a Java-based discussion that is completely applicable to the C# world.
Perhaps you want to do the following:
public interface IDay {...}
public interface IDays {...}
public interface ISpecialistDay : IDay {...}
public interface ISpecialistDays : IDays {...}
public Day : IDay {...}
public Days : IDays {...}
public SpecialistDay : ISpecialistDay
{
... ISpecialistDay methods here ...
... method proxies for IDay methods to internal Day ...
private Day _internalDay;
}
public SpecialistDays : ISpecialistDays
{
... ISpecialistDays methods here ...
... method proxies for ISpecialistDay methods to internal Days ...
private Days _internalDays;
} This way you get the inheritance of the methods without worrying about implementation.
You don't see a lot of this in C#/VB.NET because creating partial proxy objects often feels painful. Alas, it's what we've got.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|