How to get Motherboard name in VB.net? - vb.net

My program needs an upgrade and I was looking for the Motherboard name and Maker(Developer).
And here's the problem there is WMI what is offered almost everywhere, and it lines up with
Console.Writeline, what i want to do is to get the Label to show the same thing what i get with WMI.
The solution what was offered by Thorster Dittmar, did not work, I tried that at the beginning:
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.

It's a bit hard to understand your question, but what I read from it is:
You want to display information you get via WMI in a Label, but the output so far is on the Console?
Well, use the following steps:
Create a Windows Forms application
Place Label on form
Copy code that accesses WMI to Form_Load event handler
Instead of Console.WriteLine(xyz) do label1.Text = xyz
That should be it. If that doesn't answer your question, please edit your question so it becomes clearer what you want.

Related

'Watcher' program for messageboxes

I am trying to brainstorm how to go about creating a program that will be actively running alongside my application and will watch for messageboxes to be shown in the application and take all the information(text, buttons, parameters) included with that messagebox and house them as an object in a global variable available throughout my application.
Is there anyway to tell programatically in my application that a messagebox is about to appear and to take any information related to it and place it in an object? Aside from having to scan the code, which isn't what I'm looking for especially since there's many places messageboxes will appear, this would give incorrect information.
Or is there a better way to go about this? All I'm looking for is information associated with the messagebox that is about to appear(and not show the messagebox then)
Any tips or websites I could reference is greatly appreciated!!!
Create your own class that takes in the same parameters as the standard messagebox.show and then calls the messagebox.show passing the parameters on. When you are ready, you can then put some code before the standard call that will capture the information.
I always create my own messagebox.show so I can control it. It's nice to have a standard title and there maybe time that you need to do special stuff with it, like log the messages.
BTW, because of scoping, if your class is in the same project, yours will be used instead of the standard, unless you fully qualified it: system.windows.forms.messagebox.show().

Visual studio intellisense only showing after calling the right module

Been having this issue for a while now, tried to google it, but don't now really how to ask google this properly, so will try it here.
I made my own dll's, each containing different vb.net modules, each with different functions.
So for example I have a vb.net module called 'Helper', with the functions 'helper1', 'helper2', 'helper3'..
So I want to call it in a website like 'Helperdll.Helper.helper1()'.
Problem is that the intellisense already shows the functionames before I typed the modulename. So it's possible for me to call 'Helperdll.helper1(). And I want this to dissapear.
I already tried to add this just before the function. This hides indeed the functionname for the intellisense, but is not really what I'm looking for. :
'<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>'
So my question: Isn't it possible to add a rule like this one above on top of the module (so not for every function seperatly) or fix something in the properties of the dll which will hide the functionnames until the right module has been called?
That is a feature of VB.NET's Modules, it's called Type Promotion. There is no way to deactivate this behaviour.
Check if you really need a Module or if a class with Shared members would serve the same purpose for you.
Just saw that there already is a question like this: VB.NET Module - Can I force the use of <Module_Name>.Public_Member_Name when accessing pub. Members?

Detect USB - Insert/Remove - VB.NET on Windows CE 6.0

I'm becoming mad trying to figure out how to resolve this task. My goal is pretty easy, copy a file on the USB stick every time that it is inserted and then release the USB stick turning off the LED. What is the best way to solve it?
1) I found this article
http://geekswithblogs.net/BruceEitman/archive/2008/06/13/windows-ce-monitoring-for-disk-insertion-to-add-support-for.aspx
or
http://geekswithblogs.net/BruceEitman/archive/2008/06/13/windows-ce-monitoring-for-disk-insertion-to-add-support-for.aspx
but I can't translate it on VB.NET project.
2) Then I read that is enough to use RequestDeviceNotifications for block devices. But How can I do that in VB.NET?
I would like to avoid OpenNetCF if possible.
Thank you
Since you don't want to "use OpenNETCF" I assume that you don't want to use any libraries or capabilities not built in to the CF. We'll skip the argument of that silliness and the "value of your time" discussion and take that as a requirement.
What you need to do is:
Use P/Invoke to call CreateMsgQueue. That's going to give you back a Handle. You'll probably want to do CloseMsgQueue as well for completeness
P/Invoke RequestDeviceNotifications and pass it the handle returned from #1 above along with the DEVCLASS GUID value for the device notifications you want - probably STORE_MOUNT_GUID. Again, adding StopDeviceNotifications for completeness is a good idea.
At that point you'll get a message on the queue whenever a insert or remove happens. You then call ReadMsgQueue to get the DEVDETAIL data in the message.
Parse the DEVDETAIL and look at the fAttached member.
It'd take me a while to write that for you, so you'll need to do this on your own.
Start writing the project, find P/Invoke routines for the calls you need (like FindFirstFile and CreateProcess). On SO, have a look at Storage Card Problem In windows mobile and How to register form for WM_DEVICECHANGE message in windows mobile.
You are only going to be dead in the water if you can not find a particular call that you can't make.
As you work through your project, post (or search for) the actual problems you run into.
Otherwise, it sounds like you are asking someone to write the project and hand it to you.

Can I programatically get hold of the Autos/local variables that is shown when debugging?

Im trying to build an error-logger that loggs running values that is active in the function that caused the error. (just for fun so its not a critical problem)
When going in break-mode and looking at the locals-tab and autos-tab you can see all active variables (name, type and value), it would be useful to get hold of that for logging purposes when an error occur and on some other occasions.
For my example, I just want to find all local variables that are of type string and integer and store the name and value of them.
Is this possible with reflection? Any tips or pointers that get me closer to my goal would be very appreciated.
I have toyed with using expression on a specifik object (a structure) to create an automapper against a dataset, but I have not done anything like what I ask for above, so please make me happy and say its possible.
Thanks.
If you're looking to reproduce the behavior of the debugger, then you may want to be a debugger. See the Visual Studio Extensibility Learning Center. In particular, see the links under "Debuggers".

Asynch GUI updates in Smalltalk

I wondered if anybody could help me with a technique to address the following problem in Smalltalk. Specifically Cincoms Visualworks.
I would like to code a simple GUI that has three fields and processes them as follows:
The first field inputs a number (5 say).
The second field simply displays twice the first field (so it displays 10 in this example)
Now, the interesting bit... the third field displays a value from a completely different class (let's call it class X). However, the value must be displayed on the GUI whenever that value in the class X changes - it mustn't wait for a key press from an update button. The value in class X could be sourced from (say) the workspace.
I though I could do this via aspect adaptors but I can’t seem to get the 'third field value' to update asynchronously.
Any techniques, hints or tips will be most warmly welcomed - (especially code snippets!!).
Thanks
Kevin
I've sorted this myself. After trying the dependency mechanism (works fine - but simply not needed), looking at announcements (thanks James at Cincom - personal communication) I found that all I needed to do was to simply create a method and send it a message with a parameter (my value) that method then simply updated the value holder (i.e. the aspect of the GUI field) with the "value:" message. The more I look into Smalltalk the more I like it!