RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Windows Actions

Kenny164

Sorceror
If you want do simple stuff like reboot the computer, Why don't you just get C# to run a BAT file? That would be the simple way...

Although, you won't be able to find any info about the computer (e.g. drives) unless you crack into the WMI as Jeff and Mordero says.
 
Jeff;651749 said:
Code:
 foreach( ManagementObject wmi_HD in searcher.Get() )
            {
                Drive d = new Drive( wmi_HD );
                 m_Drivetable.Add( d.Model, d );
            }
Code:
public Drive( ManagementObject hdd)
        {
            m_BytesPerSector = ( uint )hdd["BytesPerSector"] ;
            m_DeviceID = ( string )hdd["DeviceID"] ;
            m_Index = ( uint )hdd["Index"] ;
            m_InterfaceType = ( string )hdd["InterfaceType"] ;
            m_Manufacturer = ( string )hdd["Manufacturer"] ;
            m_MediaType = ( string )hdd["MediaType"] ;
            m_Model = ( string )hdd["Model"] ;
            m_Name = ( string )hdd["Name"] ;   
            m_Partitions = ( uint )hdd["Partitions"] ;
            m_SectorsPerTrack = ( uint )hdd["SectorsPerTrack"] ;
            m_Signature = ( uint )hdd["Signature"] ;
            m_Size = ( ulong )hdd["Size"] ;
            m_Status = ( string )hdd["Status"];
            m_TotalCylinders = ( ulong )hdd["TotalCylinders"];
            m_TotalHeads = ( uint )hdd["TotalHeads"];
            m_MaxSectors = ( ulong )hdd["TotalSectors"];
            m_TotalTracks = ( ulong )hdd["TotalTracks"];
        }
tbchwy, I don't fully understand this. Can you explain a bit more about what that does?
 

Jeff

Lord
Storm33229;652177 said:
tbchwy, I don't fully understand this. Can you explain a bit more about what that does?

It just gets info about each Hard drive on the computer nothing more nothing less, but you can use this info for things like grabbing handles on the harddrive to read the raw sectors and such :)
 
Jeff;652196 said:
It just gets info about each Hard drive on the computer nothing more nothing less, but you can use this info for things like grabbing handles on the harddrive to read the raw sectors and such :)

do you have to use both blocks of code? or just one or the other?
 

Jeff

Lord
Storm33229;652206 said:
do you have to use both blocks of code? or just one or the other?

depends on what your doing, the 1st is kinda like a hashtable, and second is aquiring its values by using its keys :/
 

Jeff

Lord
Storm33229;652657 said:
What's casted mean? Grr.. my programming books don't tell me these things. =/

lets say you have(for this example im gonna use runuo code cause i tihnk u will understand that better)

Code:
public void Method( Mobile m )
{
   if( m is PlayerMobile )//Check if m is of type PlayerMobile
   {
       PlayerMobile pm = (PlayerMobile)m;//Cast m as a PlayerMobile
       pm.MethodTwo();
   }
}

In that example I Casted Mobile m as a PlayerMobile.

Hashtable works the same as an arraylist in the sense that whenn you pull an object out of it, its only an object and needs to be cast as its real valuetype. Dictionary<type, type> solved this issue the same way List<type> solved it for an ArrayList.
 

mordero

Knight
As a side note: when you put anything into a hashtable, its "boxes" it into an object (since everything is derived from an object). So you must "unbox" everything that comes out of a hashtable and cast it to its correct type. However, this could throw an exception if you cast it wrong, so a dictionary solves this problem because you no longer have to cast whatever you take out of it.
 

noobie

Wanderer
boxing/unboxing is only true for value types.

and casting wrong was not the problem, it was efficiency. casting objects is a very high overhead.
 
Top