Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

MarkB777

@MarkB777
About
Posts
686
Topics
101
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • USB devices, WMI and C#
    M MarkB777

    Hi all, This is more of a WMI question than C#, but for lack of a more appropriate forum I am hoping someone here will know the answer. I have a USB printer connected to my computer, and I am trying to retrieve the USB port ID for it in a C# application (i.e VID/PID). I pulled the printer details from the WMI Win32_Printer class. The problem is the port field shows USB001 (which from what I understand is just a virtual allocation). I discovered the actual USB port was a parent device called 'USB Printing Support', and the printer USB device was a child of that. I pulled the WMI class Win32_USBControllerDevice and thought I found the relationship I need:

    // The dependent here is the 'USB Printing Support' device I want to associate with the printer (and USB001)
    Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
    Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_04A9&PID_271A\\0000A1A6Q2NI"

    // The dependent here is the printer
    Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
    Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USBPRINT\\CANONLBP6000/LBP6018\\7&2509A3F3&0&USB001"

    Unfortunately the PCI bus that both devices are related with is also related with a bunch of other devices, so I am not sure this approach will work. Does anybody know a way I could programically relate my printer device with its parent USB device (Preferably one which I could pull the USB device info once it has been related to the printer) Note: If I open the properties->details window for the 'USB Printing Support' device, there is a property called 'Children' which would be perfect... I just don't know how to get to it... ;-(. Thank you.

    Mark Brock I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking

    C# csharp help tutorial question

  • Reflection question (for <= .NET 3.5)
    M MarkB777

    Thanks for your response. That is a good suggestion, but in this particular case I am trying to avoid using that approach. Much appreciated anyway

    Mark Brock I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking

    C# help question csharp announcement

  • Reflection question (for <= .NET 3.5)
    M MarkB777

    Thanks Richard that looks like it will do what I am trying to achieve, cheers mate!

    Mark Brock I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking

    C# help question csharp announcement

  • Reflection question (for <= .NET 3.5)
    M MarkB777

    Hey guys, Long story short: I have a number of classes that are structured like this:

    class ClassA
    {
    [WantToCopy]
    public Property1 { get; set; }
    public Property2 { get; set; } // ...
    }

    class ClassB : ClassA
    {
    public Property1 { get; set; }
    public Property2 { get; set; } // ...
    }

    class ClassC
    {
    public ClassB { get; set; }
    public Property1 { get; set; }
    public Property2 { get; set; } // ...
    }

    I am trying copy the ClassA values (marked with a specific attribute) from an instance of ClassB to a new instance of ClassA. This is what I am doing:

    T resp = GetClassC(); // get a pretend instance of ClassC

    var types = resp.GetType().GetProperties();
    foreach (var type in types)
    {
    // I use this to figure out if the field in ClassC == ClassB
    if(type.PropertyType.IsSubclassOf(this.GetType()))
    {
    // I use this custom method to get the properties in ClassA that have the
    // attribute mentioned above
    List fields = GetFields(type.PropertyType);
    foreach (var field in fields)
    {
    // here is the problem!
    var value = field.GetValue(resp , null); // resp is ClassC
    field.SetValue(this, value , null); // 'this' is ClassA
    }
    }
    }

    The problem is I get a TargetException when I try and get a ClassA value from a ClassC instance (which makes sense). ClassC is a generic type. I don't know anything about the ClassB member. Does anyone have any tricks that could help me out here? Or will I have to use an interface? P.S I am keen to keep this code to <= .NET 3.5 if possible. Thank you, Mark

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C# help question csharp announcement

  • Installing a filter driver
    M MarkB777

    Hi all, So this deep dive I am taking into the world of Windows driver development has got to the stage where I want to automate the installation of my driver. Ultimately I am trying to quietly install and uninstall a system filter driver (so there is no 'attached device', it gets installed under System devices). The driver I am trying to install at the moment is the cool example posted by Prikarna (Simple Serial Port Monitor). I have been playing around with dpinst, which seems to pick up the .inf file, but shows the status as not needed, because there is 'no device for update'. So if dpinst is capable of installing Prikarna's driver, I suspect the issue is something in the .inf file. #1. Is running dpinst in quiet mode with a VS2008 setup application a good approach for what I am trying to achieve? If dpinst is a good approach.. #2. What are the key tags/sections that need to be added to an .INF file (or some other file?) to have dpinst install a filter driver under System Devices? Thank you, Mark.

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    Hardware & Devices announcement com help tutorial question

  • Is there a reason you would initialise variables like this?
    M MarkB777

    Thanks George :)

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC oop question announcement

  • Is there a reason you would initialise variables like this?
    M MarkB777

    Hi all, Is there any particular reason you would initialise private members of a class like this... SomeClass::Constructor(void): privateVar1(NULL), privateVar2(true) { } As opposed to this? SomeClass::Constructor(void) { privateVar1 = NULL; privateVar2 = true; } From what I understand the first instance would be useful when inheritance is involved.. Perhaps this is just a favored style? Cheers, Mark

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC oop question announcement

  • Getting a driver to work in a managed environment
    M MarkB777

    Great, thanks Richard ;)

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    Hardware & Devices csharp c++ question announcement workspace

  • Getting a driver to work in a managed environment
    M MarkB777

    Hi all, I have a simple driver which compiles and loads fine, and a simple C++ application which can read data being output from it. What I am ultimately trying to do is get the data being spat out from the driver into a C# application (which I would prefer to use to do the GUI side of things). My plan at the moment is to create a .dll, which would have the C++ code to read from the driver, and a buffer which would be exposed to the C# application to read the data. I have not got to the point of trying this yet, but from what I have been reading online I get the impression that mixing managed and unmanaged code is a nightmare. So I have two questions: #1. Am I on the right track with this plan of mine? #2. If I am not on the right track, does anyone who has been through all of this have any tips, or good articles that can get me moving in the right direction? Thankyou, Mark.

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    Hardware & Devices csharp c++ question announcement workspace

  • Optimisation challenge...
    M MarkB777

    Will do... I'm going to give this a crack too.. http://en.wikipedia.org/wiki/Duff%27s_device It will be interesting to see the different execution times of all these methods.

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC announcement

  • Optimisation challenge...
    M MarkB777

    Hi Chris, Awesome answer! I do know all the (expected) lengths. I'll give your idea a go tonight! The first two strcpy calls are horrible... But for some reason the function wouldn't work without them... maybe something to do with the Atmel compiler.. Thanks,

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC announcement

  • Optimisation challenge...
    M MarkB777

    Hi Aescleal, Thanks for your answer. I should been more explicit though. Its a C compiler, STRING is a type definition. The code is in an Atmel microcontroller and has very little space left in flash for more code, that was why I used the global variable instead of a local pointer each time the function was called. A work mate pointed out I could use sprintf.. which would likely be no faster, but it would be much cleaner looking. Your right about the macro calls - I'm going to take those out. Thanks,

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC announcement

  • Optimisation challenge...
    M MarkB777

    Hi all, I've got a nasty looking chuck of code that is just asking to be written better... The function as it is works... It converts the two double parameters to string format (using a macro that I havent added below), and then joins them all together (along with the headers that are already in string format). Would be great if someone could let me know a more eligant way to join the strings than the way I have done it... static inline STRING lcd_ConstructLine(STRING pcH1, double dV1, STRING pcH2, double dV2) { char acBuff1[CONV_DOUBLE_STRING_SIZE]; char acBuff2[CONV_DOUBLE_STRING_SIZE]; strcpy(acBuff1, lcd_String(dV1)); strcpy(acBuff2, lcd_String(dV2)); strcpy(_acLine, pcH1); strcat(_acLine, acBuff1); strcat(_acLine, pcH2); strcat(_acLine, acBuff2); return(_acLine); }

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C / C++ / MFC announcement

  • A function that does... nothing... :-).
    M MarkB777

    No its used as a handler function in a state machine. The function is really just a bi-product of the design... but still... I thought it was funny :).

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    The Weird and The Wonderful announcement

  • A function that does... nothing... :-).
    M MarkB777

    /******************************************************************************
    FUNCTION : lpf_Null
    DESCRIPTION : Does nothing.
    ******************************************************************************/
    static void lpf_Null(void)
    {

    }

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    The Weird and The Wonderful announcement

  • Helpful comment
    M MarkB777

    Found this description on a function called "Periodic" yesterday. "This function is periodic, it runs periodically. This function will be executed every period" :-D

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    The Weird and The Wonderful announcement

  • Visual studio custom build
    M MarkB777

    Hi, We are currently using the Eclipse IDE to develop our code. We build our project by running a make file. Is there a way in Visual Studio (2005) that whenever I build the project it executes a make file of my choice? Cheers, Mark.

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    Visual Studio visual-studio csharp question announcement

  • Kanye West
    M MarkB777

    that episode was halarious!!

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    The Soapbox swift com tutorial announcement career

  • validate an email address
    M MarkB777

    Hi there, Have a look into CAPTCHA's. If you don't like this, another option to add a hidden textbox. Spam bots will generally fill in every box on the page (hidden or not) and then submit the form. All you have to do is check that the hidden box is empty - if not, it is a non-human user. Cheers,

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C# question

  • Click Once Deployment
    M MarkB777

    Hi Abdul, If you open your project properties, and look in the "publish" section, you can find settings for all of this (required assemblies etc etc). Click Once enables you to create a bootstrapper that will install additional software, either from the server you are hosting the application on, or from the vendors homepage. Hope this helps,

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    C# csharp database dotnet adobe sysadmin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups