mIRC Home    About    Download    Register    News    Help

Print Thread
#237145 15/04/12 05:22 AM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Not sure if this is a bug or not.

The $bits identifier has existed since early in the mirc 5.x versions, and answered 16 or 32 to indicate whether it was running the 16bit or 32bit variant of mirc.

Is there any intention to have $bits report whether mirc is using the 32 or 64bit version of Vista or Win7?

As of 7.22, $bits still returns 32 always.


maroon #237146 15/04/12 09:38 AM
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
Although you may be running a 64-bit OS, the mIRC application is still only a 32-bit application. The intention of the $bits identifier is to tell you which version of the application you are using, not what your OS supports.

There really aren't any compelling reasons to rewrite mIRC as a 64-bit application (and there are even some disadvantages), so I doubt there are any plans to rewrite mIRC as a 64-bit application at this point in time.

maroon #237153 15/04/12 05:05 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Not a bug. mIRC is a 32bit executable as pointed out above. Eventually mIRC was released as a 32bit executable-- and eventually mIRC will be released as a 64bit executable, but that probably won't happen any time soon. The difference with the 16/32 issue is that back in the day there were no 16bit emulation layers on 32bit platforms, so mIRC had to be released in two different executables. These days there is no point in releasing a 64bit version until 32bit machines are all gone and support for the compat layer in the hardware architecture is dropped. Again, that probably won't happen for quite a while.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #237155 15/04/12 07:13 PM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
ok thanks, i was mis-understanding what the $bits was telling us, since $os just says Vista or Win7 without indicating whether it's Vista-32 or Vista-64.

I'm guessing the best way to see if someone has 64-bit is to see if $isfile(c:\windows\system32\command.com) is $false?

maroon #237158 15/04/12 08:13 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The "proper" way seems to be described in http://stackoverflow.com/questions/601089/detect-whether-current-windows-version-is-32-bit-or-64-bit

A little script would be:

Code:
alias platform_bits {
  .comopen a WScript.Shell 
  noop $com(a,RegRead,3,bstr,HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\Platform Id)
  var %value = $com(a).result
  .comclose a
  return $base(%value,16,10)
}


Note: on my 64bit system this value returns 2h, not 40h, for some reason. I can't tell if this is just a broken registry or the same for other systems. You could add $iif($base(%value,16,10) == 32,32,64) to the result to ensure that it only returns 32/64.

But yes, there are probably a lot of other hacks that can be fairly reliable-- another would be checking for a "C:\Program Files (x86)\" folder, which would indicate a 64bit machine.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #237159 15/04/12 08:38 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
https://forums.mirc.com/ubbthreads.php/ubb/showflat/Number/230779/page/2

See FroggieDaFrog's first comment and the comment following it, should do the job, even for you


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #237164 16/04/12 03:18 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The code I posted does the job, "even for me". But yes, that is another way to do it. There are many.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #237171 16/04/12 02:05 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Your code simply doesn't work on my 64bits system..

Last edited by Wims; 16/04/12 02:05 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
argv0 #237191 16/04/12 06:19 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
nor does it work on mine, for some reason


I refuse to engage in a battle of wits with an unarmed person. wink
argv0 #237192 16/04/12 06:34 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Tested the code here, dont work on win 7 32 bits ultimate.

;---- edit

Grapic drivers do use the same bits as your system, so why not grab the bits from there?

//echo -a $wmiget(Win32_VideoController).currentbitsperpixel

You dont install 32 bit drivers on a 64 bit system. Just a idea.

Last edited by sparta; 16/04/12 06:37 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #237193 16/04/12 06:41 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
It's not a problem with the code, which in itself is fine, it's just that we don't have that entry in our registry, that's why I suggested the other way, it seems much more reliable

Last edited by Wims; 16/04/12 06:45 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
sparta #237196 16/04/12 09:47 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I haven't done much with drivers in COM, but I know that graphics information in COM is often sketchy. Sometimes it's there and sometimes it isn't, depending on the card. If the driver information isn't always available, then it's probably not the best option. I'd stick to using the OS Architecture (as mentioned in the link Wims posted above) as long as this isn't going to be used on an old system where that property isn't available.

Also, that property sounds like it's the color depth and not the driver architecture. If that's the case, most people are using 32bit color depth and that isn't related to your OS architecture. If it really is the driver architecture, then ignore this part, but the first paragraph still stands.

Btw, this is what Invision uses. I got help with it a couple years ago on these forums and adjusted it some since then. It takes a 3rd value that lets you obtain details when more than one item is present.

Code:
iSystem {
  ; $1 = Win32_Class
  ; $2 = Item Requested
  ; $3 = Device Number
  .comopen xpver1 WbemScripting.SWbemLocator
  .comclose xpver1 $com(xpver1,ConnectServer,1,dispatch* xpver2)
  if $com(xpver2) {
    .comclose xpver2 $com(xpver2,ExecQuery,1,bstr*,select $2 from Win32_ $+ $1,dispatch* xpver3)
    if $com(xpver3) {
      var %a = $comval(xpver3,$3,$2)
      .comclose xpver3
      return %a
    }
  }
}


For example, if I wanted to check my drives, I probably wouldn't want just the first controller. So, with this, I can do:

//echo -a $isystem(DiskDrive,Caption,1)
//echo -a $isystem(DiskDrive,Caption,2)
//echo -a $isystem(DiskDrive,Caption,3)

And the output would be:
Maxtor 6L300R0 ATA Device
ST3500630AS ATA Device
WDC WD1001FALS-00J7B0 ATA Device

Of course, I probably wouldn't be interested in that information, but that's just an example. You can use a loop to get all of the information if needed and using 0 as the third parameter will tell you how many devices there are.

It is basically the same as was already shown, but I wanted to show how to make use of the third parameter.

*Note: This automatically fills in Win32_, so you don't need to specify that when using it. However, if you want to access any COM object other than the Win32_ ones, you'll need to remove that from the script and then include it in the parameter instead.


Invision Support
#Invision on irc.irchighway.net
maroon #237198 17/04/12 02:54 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Using:
Code:
alias osBits {

  var %r

  if ($com(WMILoc)) { .comclose WMILoc }
  if ($com(WMISrv)) { .comclose WMISrv }
  if ($com(WMIGet)) { .comclose WMIGet }

  .comopen WMILoc WbemScripting.SWbemLocator
  if ($comerr) { goto error }
  elseif (!$com(WMILoc,ConnectServer,3,dispatch* WMISrv)) { goto error }
  elseif (!$com(WMISrv,ExecQuery,3,bstr*,select OSArchitecture from Win32_OperatingSystem,dispatch* WMIGet)) { goto error }
  %r = $iif($gettok($comval(WMIGet,1,OSArchitecture),1,$asc(-)),$v1,32)

  :error
  if ($com(WMILoc)) { .comclose WMILoc }
  if ($com(WMISrv)) { .comclose WMISrv }
  if ($com(WMIGet)) { .comclose WMIGet }
  return %r
}


You *should* be able to use:
Code:
//echo -a $osBits


which should return: "64" for 64bit machines, or "32" for all others.

Last edited by FroggieDaFrog; 17/04/12 03:15 AM.

I am SReject
My Stuff
Wims #237200 17/04/12 08:00 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I'd be curious to know what version of Windows you're running. I'm testing this on Win7. It might be specific to that.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #237201 17/04/12 08:50 AM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I'm also using windows 7, but the information your script is retieving seems to be related to the processor


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
argv0 #237202 17/04/12 10:15 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Windows 7 32bit here and no Platform ID in my registry either. Besides, that's the processor and not necessarily the OS like Wims mentioned. I wouldn't want to use the registry for it anyhow. 64 and 32 bit registries are different as are other OS registries, so expecting a key to be the same and in the same place if you're distributing your script is probably not a good idea. Certain keys may always be in the same place (Run, for example, though there are multiple Run keys and some of those vary by OS and architecture). But I'm not so sure about hardware keys. If it was always there, then sure, but it looks like it's not always available even on Windows 7.

@Froggie, yes, the OS Architecture property is probably the best option. However, as I mentioned in the thread that was linked above, that property is limited to certain versions of Windows. That may or may not be a problem depending on your needs.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
The thing is. only windows vista and later have a 64bit version.
xp and win2k are 32bit, and I seriously doubt anyone is still using a windows version before that. So I saw no need to clutter up code for maybe 0.01% of the people that would need the info for such OSs


I am SReject
My Stuff
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Originally Posted By: FroggieDaFrog
The thing is. only windows vista and later have a 64bit version.
xp and win2k are 32bit, and I seriously doubt anyone is still using a windows version before that. So I saw no need to clutter up code for maybe 0.01% of the people that would need the info for such OSs

Windows XP has 64 bit.

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
welp. Guess i'll have to make a work around for xp 64bit


I am SReject
My Stuff
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
$isdir(C:\Program Files (x86))


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard