|
now how's that? I finally figure it out... I will use that from now on. Lesson learned about the use of <pre> for code readability.
|
|
|
|
|
Much better, it is readable now.
Some questions:
1.
Why are you using Marshal.ReadInt32()? I never needed such functions, and I've done my share of device arrival handling.
2.
What is the exact line that fails? or: why don't you have a try-catch inside OnDeviceChange?
3.
Have you searched CodeProject? Detecting Hardware Insertion and/or Removal[^] is an article that may interest you.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I did check "detecting Hardware Insertion and/or removal... it was written in C++ and I don't quite understand.
On the line after "HID_API.DBT_DEVICEARRIVAL": "int devType = Marshal.ReadInt32(m.LParam, 4);" is where the access memory violation.
I am not expert on hardware interfacing and am currently learning, especially when it comes to WndProc stuff.
I'll try "try-catch".
You said u have done your share of device arrival handling. How do u handle it?
|
|
|
|
|
See Alan's reply.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi,
I'd question the correctness of the the LParam when you send the message
SendMessage(this.Handle.ToInt32(), HID_API.WM_DEVICECHANGE, HID_API.DBT_DEVICEARRIVAL, (IntPtr)HID_API.DBT_DEVTYP_DEVICEINTERFACE);
Code I've seen and used has the LParam as a pointer to a DEV_BROADCAST_HDR structure. You're passing the value HID_API.DBT_DEVTYP_DEVICEINTERFACE (5?) which is never going to a be valid pointer.
[StructLayout(LayoutKind.Sequential)]
internal struct DEV_BROADCAST_HDR {
internal int dbcv_size;
internal DeviceType dbcv_devicetype;
internal int dbcv_reserved;
}
Alan.
|
|
|
|
|
Now its working! Thanks for the help!
|
|
|
|
|
Now one more thing...
The usb device detection & event does work when the software is running.
Now the question is how do i initiate the WM_DEVICECHANGE event at start up? So that when the usb devices are on and when the software is being created (during WM_CREATE) message.
|
|
|
|
|
Alan's reply is perfect. Here is the link[^] to msdn documentation for DBT_DEVICEARRIVAL event. See how lparam is defined.
|
|
|
|
|
Hi there,
I need to be able to zoom in on a label without changing the text size (i.e. feed it a zoom factor, such as 2, and have it enlarge on the screen by that amount).
Basically, a series of labels are part of a component used to set text sizes/layouts on a page. The component needs 'zoom' capability - e.g. zoom to 2x magnification. Clearly, changing the text size would be easy, but this means when the page is saved, the text sizes would have to be changed back ('rescaled') to zoom 1x, which seems awfully messy (esp if the user wants to edit the text size while it's zoomed). Is there an easier/less bothersome way? These do not *HAVE* to be labels, if a solution exists for a similar control (they could be, e.g. uneditable textboxes)...
any help would be greatly appreciated
thanks
Lee
EDIT: I ended up simply having to change the text size, in the 'messy' fashion I described above. It wasn't ideal, but did the job.
modified on Thursday, February 17, 2011 9:08 PM
|
|
|
|
|
The only thing that springs to mind is to have a 'dummy' control that overlies the 'real' one and does all the zooming when anything other than 1x is selected.
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.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
If you are using WPF you can use an Animation, which will take care of restoring the original value when the animation ends (provided you configure it correctly).
Otherwise you could create a disposable helper class that can animate a property value, including storing the original value and restoring it at the end.
|
|
|
|
|
This is my code
reqFTP = FtpWebRequest.Create(new Uri("ftp:\\1.1.1\myfile")) as FtpWebRequest;
if (reqFTP != null)
{
reqFTP.Proxy = null;
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.Credentials = new NetworkCredential("username", "pwd");
reqFTP.UseBinary = true;
using (FtpWebResponse response = reqFTP.GetResponse() as FtpWebResponse)
myfile is the file with no extension
when i debug i get an error in response = reqFTP.GetResponse() as below
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
pls help to solve this
thanks in advance
|
|
|
|
|
That seems pretty straightforward. There is no file matching this at that location. BTW, you should use / not \ in your URI.
|
|
|
|
|
|
FYI: chances are the FTP site is treating file names in a case-sensitive way, unlike Windows, so you'd better make sure the casing is correct.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Actually now i am on a c#.net windows application project.That shows the data from its database
in the form.So i am planning to add new data into database through text files.Actually i have 'FOUR' fields in the database
,So how to add the proper data into those fields from a single text file.I need a wise response.I hope you got my issue.Please..
|
|
|
|
|
please don't cross post you have already posted this question there[^].
you already got answer if you have any query then you should stick there and ask to answerer.
|
|
|
|
|
|
I'm sorry, but it's extremely unlikely that anybody here is going to download a file from an unknown source.
|
|
|
|
|
Hi, it just from google docs.
how can i attach here?
Socheat
|
|
|
|
|
I know Google docs. You, I don't know.
|
|
|
|
|
Nope, I'm with Pete on this: anonymous files from unknown people equals no download. Particularly when the person in question names him self "soCHEAT.net". Not promising...
Instead, why not describe what the file is supposed to contain. What file type is it? .DOC, .XLS, .XXX? What application would normally open it? What app created it?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Do you know Huawei Switch? that file is generated from MSC it is CDR. it stored call record for phone number
Socheat
|
|
|
|
|
Presumably you can get the specifications from Huawei then, or an API. I'd be really surprised if they didn't have this information available.
|
|
|
|
|
Yes they have description and format of that file, but i don know how to decode that file in C#. That why i posted that file here.
If anyone can't decode, there nothing
Thanks,
Socheat
|
|
|
|