WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

RAS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List RAS Capable Devices


#DefineFunction RasListDevices(flag)
	;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	;RasListDevices(flag)
	;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	;Returns the name and type of all available RAS-capable devices
	;
	;Parameters:
	;(i) flag 		0 - lists device names
	;					1 - lists device types
	;					2 - List device name and device type in the format:
	;						 {Name}|{Type}
	;Returns:
	;(s)				tab delimited list of devices
	;
	;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	structsize = 152
	handle = DllLoad(StrCat(Dirwindows(1),"Rasapi32.dll"))
	
	;Determine size of structure
	lpSize = BinaryAlloc(4)
	lpCount = BinaryAlloc(4)
	BinaryEodSet(lpSize,0)
	BinaryEodSet(lpCount,0)
	BinaryPoke4(lpSize,0,0)
	ret = DllCall(handle,long:"RasEnumDevicesA",lpnull,lpbinary:lpSize,lpbinary:lpCount)
	bufsize = Binarypeek4(lpSize,0)
	
	;Enumerate Devices
	lpRasDevInfo = BinaryAlloc(bufsize)
	BinaryEodSet(lpRasDevInfo,0)
	BinaryPoke4(lpRasDevInfo,0,structsize)
	ret = DllCall(handle,long:"RasEnumDevicesA",lpbinary:lpRasDevInfo,lpbinary:lpSize,lpbinary:lpCount)
	if ret != 0
		  Message("RasListDevices Error", DllLastError())
		  BinaryFree(lpCount)
		  BinaryFree(lpSize)
		  BinaryFree(lpRasDevInfo)
		  exit
	endif
	
	count = BinaryPeek4(lpCount, 0)
	bufsize = BinaryPeek4(lpSize, 0)
	BinaryEodSet(lpRasDevInfo,bufsize) 
	eod = BinaryEodGet(lpRasDevInfo)
	list = ""
	structptr = 0
	typesize = 17
	for x = 1 to count
			nameptr = structptr+21
			typeptr = structptr+4
			Switch flag
	 		   case 0
					name = BinaryPeekstr(lpRasDevInfo,nameptr,structsize)
					list = StrCat(list,@tab,name)
					break
				case 1
					type = BinaryPeekstr(lpRasDevInfo,typeptr,typesize)
					list = StrCat(list,@tab,type)
					break
	 		   case 2
					name = BinaryPeekstr(lpRasDevInfo,nameptr,structsize)
					type = BinaryPeekstr(lpRasDevInfo,typeptr,typesize)
					list = StrCat(list,@tab,name, "|",type)
					break
				case flag
				   Message("RasListDevices Error", "Invalid flag value")
						BinaryFree(lpCount)
						BinaryFree(lpSize)
						BinaryFree(lpRasDevInfo)
						Return list
					break
			EndSwitch
			structptr = structptr+structsize
	next
	list = StrTrim(list)
	BinaryFree(lpCount)
	BinaryFree(lpSize)
	BinaryFree(lpRasDevInfo)
	Return list
#EndFunction

flag = 2
raslist = RasListDevices(flag)
AskItemlist("List of RAS-capable devices",raslist,@tab,@unsorted,@single)

Article ID:   W15866
File Created: 2004:03:30:15:41:12
Last Updated: 2004:03:30:15:41:12