Discussion Forums > Technology
Programming Questions | Repositories
kitamesume:
i think i found something else, mind if anyone can evaluate it?
from : http://www.codeproject.com/Articles/32330/A-Useful-WMI-Tool-How-To-Find-USB-to-Serial-Adapto
--- Code: ---
//Below is code pasted from WMICodeCreator
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSSerial_PortName");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("PortName: {0}", queryObj["PortName"]);
//If the serial port's instance name contains USB
//it must be a USB to serial device
if (queryObj["InstanceName"].ToString().Contains("USB"))
{
Console.WriteLine(queryObj["PortName"] + "
is a USB to SERIAL adapter/converter");
}
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
--- End code ---
where as "PortName" is the variable where commport is assigned right?
though this is a C# code, i wonder if theres an equivalent code for VB6.
--------------------------------------------------------------------------------------------------
also a different question, i'm searching for a free OS mainly for VB6 programming and/or executing the program itself.
the problem is that, the system the OS is meant to be installed to is sold to customers in bundled with the program (don't ask what it is, too long to explain) so buying a legal copy of windows is expensive and will cut my profit a lot...
thinking of linux might work so i'm asking if theres any legit site for downloading a legal copy of linux. also which flavor of linux would be the easiest to manipulate and the least problematic at that(noob proof to be precise).
Bob2004:
--- Quote from: kitamesume on March 19, 2012, 08:51:36 AM ---i think i found something else, mind if anyone can evaluate it?
from : http://www.codeproject.com/Articles/32330/A-Useful-WMI-Tool-How-To-Find-USB-to-Serial-Adapto
--- Code: ---
//Below is code pasted from WMICodeCreator
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSSerial_PortName");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("PortName: {0}", queryObj["PortName"]);
//If the serial port's instance name contains USB
//it must be a USB to serial device
if (queryObj["InstanceName"].ToString().Contains("USB"))
{
Console.WriteLine(queryObj["PortName"] + "
is a USB to SERIAL adapter/converter");
}
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
--- End code ---
where as "PortName" is the variable where commport is assigned right?
though this is a C# code, i wonder if theres an equivalent code for VB6.
--- End quote ---
Well, that seems to use the WMI (Windows Management Instrumentation), parts of which are available in VB6 - I don't know about the specific functions used there, but you should look up the documentation on how to use WMI in VB6, and see if you can find any details on the functions used in that code, or their equivalents. If you can find functions to do the same thing, then you might well be able to make it work using the same structure as that code.
--- Quote ---also a different question, i'm searching for a free OS mainly for VB6 programming and/or executing the program itself.
the problem is that, the system the OS is meant to be installed to is sold to customers in bundled with the program (don't ask what it is, too long to explain) so buying a legal copy of windows is expensive and will cut my profit a lot...
thinking of linux might work so i'm asking if theres any legit site for downloading a legal copy of linux. also which flavor of linux would be the easiest to manipulate and the least problematic at that(noob proof to be precise).
--- End quote ---
Visual Basic 6 was designed with Windows 98 in mind, and hasn't been used by 99.99% of programmers for years - it does not run on Linux, full stop. There have been a few attempts to port VB6 I think, so it might be worth checking some of them out, but I don't believe any of them have ever reached the point where they're actually suitable for use. And some would probably be so old now that they might not work on modern Linux distributions anyway.
There is a Linux port of the .NET runtime, called Mono, which can run C# and VB.NET programs in Linux, OSX, iOS, and Android - but it does not support VB6, at all. VB6 barely runs in Windows 7 as it is, let alone Linux.
So yeah, it's Windows, or switch to a language that isn't quite so ancient. I'm not sure how easy it is to port VB6 code into VB.NET, and you'd have to do a fair bit of fiddling around with it to get it to work, but if you want to use any OS other than Windows, that's your best bet.
Freedom Kira:
--- Quote from: kitamesume on March 19, 2012, 08:51:36 AM ---where as "PortName" is the variable where commport is assigned right?
though this is a C# code, i wonder if theres an equivalent code for VB6.
--- End quote ---
You can probably write an equivalent, but it'd be a pain because of all the code that probably goes into the ManagementObjectSea rcher object that is hidden from you.
VB6 doesn't have any exception try/catch handling afaik, so your equivalent wouldn't be entirely equivalent. Everything else, sans the searcher thing mentioned above, should be rewritable.
Also, what Bob said. If this is for a school project, start complaining to your school about using VB6. If it's for work, start complaining to your boss about using VB6. And if it's neither, you have made a terrible choice for a language. There are plenty of scripting languages out there that are better to learn - Perl, Python, PHP, Ruby, to name a couple.
kitamesume:
so if what you guys suggesting is that VB6 is nearly obsolete if not entirely, then which language should i switch to that runs flawlessly on linux? C# maybe?
though thats a fresh start from scratch if its not familar to me, i got too used to VB6.
also, as i've asked before, which flavor of linux would you guys prefer as a programming station? the easier the os can be managed the better and least problematic at that. theres just too many flavors to choose from and its been more than a decade since i last saw a linux system.
i might just end up renaming this whole thread to "programming questions | repositories" hahaha.
Bob2004:
The final release of VB6 was early 1998. It was made obsolete in 2005. Extended support ended early 2008. So yeah, it is just a little out of date :P
I made a couple of suggestions for similar languages in my last post which will also run on Linux. VB.NET is very similar to VB6, and C# is also similar (and significantly better). You'll want to program them on windows, with Visual Studio, but porting your application to Linux is possible. For easier portability, you could also try Java - it will run on most desktop OSes without any porting needed at all, and there are good IDEs available for Linux and Windows, too. It's less similar to VB than the other two, and honestly I prefer C#, but it's all a matter of opinion.
--- Quote from: Freedom Kira on March 19, 2012, 03:45:15 PM ---You can probably write an equivalent, but it'd be a pain because of all the code that probably goes into the ManagementObjectSea rcher object that is hidden from you.
--- End quote ---
Actually, the ManagementObject stuff is all part of WMI, so it is quite possible that there will be equivalent functions which can be used in VB6. I think you have to do a bit of configuring to load WMI into your project, but after that it gives you access to a lot of stuff, including COM ports (though the stuff available for Windows 98, and therefore VB6, is more limited). The structure should be broadly similar across all languages it supports, so if that feature is supported in windows 98, then it would probably be implemented in a similar manner.
You'd have to find the documentation for the WMI VB6 plugin, I suppose.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version