Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘windows millennium edition’

How To Troubleshoot Run-time Error ‘70′ in DCOM Applications

Symptoms
Attempting to access a DCOM Server from a remote client application sometimes results in the following error:

Run-time error ‘70′:
Permission Denied
This article describes the most common scenarios in which this error is raised.
Resolution
Run-time error ‘70′ is typically the result of a security or permissions issue. The following is a list of possible causes of run-time error 70 but is by no means a complete or definitive list.
DCOM Is Not Enabled If the Server machine does not have DCOM enabled, client machines will receive run-time error 70 when attempting to access the server. This scenario applies to Windows 2000, Windows NT, Windows 95, Windows 98, and Windows Millennium Edition (Me) servers:
On the Server machine, run DCOM Config (DCOMCNFG.EXE). Choose the Default Properties tab. Ensure that Enable Distributed COM on this computer is checked. This value is stored in the Windows Registry at the following location:
HKEY_LOCAL_MACHINE\Software\Microsoft\OLE
The Client User Does Not Have Sufficient Permissions If the client user does not have the correct permissions, access to the DCOM Server can be denied. There are several steps to take in order to ensure your client has valid privileges.
If the Server is Windows 95, Windows 98, or Windows Me:
Run DCOM Config. Select the DCOM Server application from the list of available applications. Select the Properties button, or double-click the DCOM Server application in the list. Test the server with “Default Access Permissions.”
If run-time error ‘70′ still occurs, the default access permissions are restricting your user. If this is the case, then modify the Default Access Permissions from the Default Security tab in DCOM Config. Grant the client user access permissions.
If run-time error ‘70′ does not occur running with default access permissions, it is likely that the custom access permissions are restricting your client from accessing the DCOM Server. Choose custom access permissions and select the Edit button. Grant the client user access permissions. If the Server is Windows NT or Windows 2000:
Run DCOM Config. Select the DCOM Server application from the list of available applications. Select the Properties button, or double-click the DCOM Server application in the list. Test the server with “Default Access Permissions,” “Default Launch Permissions,” and “Custom Configuration Permissions.”
If run-time error ‘70′ still occurs, it is likely that the default access permissions are restricting your user. If this is the case, modify the Default Access Permissions from the Default Security tab in DCOM Config.
If run-time error ‘70′ does not occur, it is likely that the custom access permissions are restricting your client from accessing the DCOM Server. Choose to use Custom access permissions and choose the Edit button. Grant the client user account access permissions, or grant a group the client user belongs to access permissions. For more information regarding security groups on Windows NT see the table to follow.
There are several group accounts you will find when you configure users and groups on Windows NT and Windows 2000. The following list is a summary of who belongs to each group:

GroupDescription————————————————————————–InteractiveIncludes all users who log onto a Windows NT orWindows 2000 system locally (at the console). Itdoes not include users who connect to NTresources across a network or are started as aserver.NetworkIncludes all users who connect to Windows NT orWindows 2000 resources across a network. It doesnot include those who connect through aninteractive logon.Creator/OwnerThe Creator/Owner group is created for eachsharable resource in the Windows NT orWindows 2000 system. Its membership is the set ofusers who either create a resource (such as afile) and who take ownership of them.EveryoneAll users who access the system, whether locally,remotely, or across the network.SystemThe local operating system.
The above list includes the group accounts which are intrinsic to Windows NT and Windows 2000 systems. Your particular network may include more groups from which you may choose. In order to determine the membership of each custom group account, you must contact your network administrator.

The DCOM Server Raises Events to the Client If your DCOM server component raises events that are handled by the client application, you must configure DCOM security on the client computer to allow access, and you must configure DCOM security on the server computer. This allows the server to make callbacks to the client, so the event can be raised. If you do not configure DCOM security in this way, error 70 is generated whenever the client application calls the server. This results in an event being raised back to the client. If the server application does not raise events, you do not have to configure DCOM security on the client computers.
If the client computer is running Windows 95, Windows 98, or Windows Me, follow these steps:
Run DCOM Config (DCOMCNFG.exe). Click the Default Security tab. Click the Edit Default button. Click the Add button. Click to select The World, and then click the Grant Access button to grant permissions. Click Ok to close the Add Access Permissions dialog box. Click Ok to close the Access Permissions dialog box. Click Ok to close the DCOM Config Properties dialog box. Test the application again.
The client application successfully handles the event.
If the client computer is running Windows NT orWindows 2000, follow these steps:
Run DCOM Config (DCOMCNFG.exe).Click the Default Security tab. Click the Edit Default button. Click the Add button.Click to select the Everyone account, and then click to select Allow Access in the Type of Access box. Click Ok. Click Ok again to close the Registry Values Permission dialog box. Click Ok to close the DCOM Config Properties dialog box. Test the application again.
The client application successfully handles the event.
Attempting to Access DCOM Server Across Non-Trusted Domains If your DCOM Server resides in one Windows NT or Windows 2000 domain, and your client logs on to a second Windows NT or Windows 2000 domain that is not “trusted” by the first, you will receive run-time error ‘70′ when attempting to access the DCOM Server.

How To Call GetNetworkParams/GetAdaptersInfo From Visual Basic

Symptoms
This article illustrates how to programmatically retrieve IP configuration information similar to the IPCONFIG.EXE utility. It demonstrates how to use the IP Helper APIs GetNetworkParams() and GetAdaptersInfo() from Visual Basic.
The libraries called by the code sample in this article are only supportedon the following platforms:
Microsoft Windows 2000
Microsoft Windows 98
Microsoft Windows Millennium Edition (Me)Running it on any other platform results in an error.
Resolution
Start a new Visual Basic Standard EXE project. Form1 is created by default.On the Project menu, click Remove Form1.On the Project menu, click Add Module. Module1 is created by default.Paste the following code in the General Declarations section of Module1:

Public Const MAX_HOSTNAME_LEN = 132Public Const MAX_DOMAIN_NAME_LEN = 132Public Const MAX_SCOPE_ID_LEN = 260Public Const MAX_ADAPTER_NAME_LENGTH = 260Public Const MAX_ADAPTER_ADDRESS_LENGTH = 8Public Const MAX_ADAPTER_DESCRIPTION_LENGTH = 132Public Const ERROR_BUFFER_OVERFLOW = 111Public Const MIB_IF_TYPE_ETHERNET = 6Public Const MIB_IF_TYPE_TOKENRING = 9Public Const MIB_IF_TYPE_FDDI = 15Public Const MIB_IF_TYPE_PPP = 23Public Const MIB_IF_TYPE_LOOPBACK = 24Public Const MIB_IF_TYPE_SLIP = 28Type IP_ADDR_STRINGNext As LongIpAddress As String * 16IpMask As String * 16Context As LongEnd TypeType IP_ADAPTER_INFONext As LongComboIndex As LongAdapterName As String * MAX_ADAPTER_NAME_LENGTHDescription As String * MAX_ADAPTER_DESCRIPTION_LENGTHAddressLength As LongAddress(MAX_ADAPTER_ADDRESS_LENGTH – 1) As ByteIndex As LongType As LongDhcpEnabled As LongCurrentIpAddress As LongIpAddressList As IP_ADDR_STRINGGatewayList As IP_ADDR_STRINGDhcpServer As IP_ADDR_STRINGHaveWins As BytePrimaryWinsServer As IP_ADDR_STRINGSecondaryWinsServer As IP_ADDR_STRINGLeaseObtained As LongLeaseExpires As LongEnd TypeType FIXED_INFOHostName As String * MAX_HOSTNAME_LENDomainName As String * MAX_DOMAIN_NAME_LENCurrentDnsServer As LongDnsServerList As IP_ADDR_STRINGNodeType As LongScopeIdAs String * MAX_SCOPE_ID_LENEnableRouting As LongEnableProxy As LongEnableDns As LongEnd TypePublic Declare Function GetNetworkParams Lib “IPHlpApi.dll” _(FixedInfo As Any, pOutBufLen As Long) As LongPublic Declare Function GetAdaptersInfo Lib “IPHlpApi.dll” _(IpAdapterInfo As Any, pOutBufLen As Long) As LongPublic Declare Sub CopyMemory Lib “kernel32″ Alias “RtlMoveMemory” _(Destination As Any, Source As Any, ByVal Length As Long)Sub main()Dim error As LongDim FixedInfoSize As LongDim AdapterInfoSize As LongDim i As IntegerDim PhysicalAddressAs StringDim NewTime As DateDim AdapterInfo As IP_ADAPTER_INFODim AddrStr As IP_ADDR_STRINGDim FixedInfo As FIXED_INFODim Buffer As IP_ADDR_STRINGDim pAddrStr As LongDim pAdapt As LongDim Buffer2 As IP_ADAPTER_INFODim FixedInfoBuffer() As ByteDim AdapterInfoBuffer() As Byte’ Get the main IP configuration information for this machine’ using a FIXED_INFO structure.FixedInfoSize = 0error = GetNetworkParams(ByVal 0&, FixedInfoSize)If error <> 0 ThenIf error <> ERROR_BUFFER_OVERFLOW ThenMsgBox “GetNetworkParams sizing failed with error ” & errorExit SubEnd IfEnd IfReDim FixedInfoBuffer(FixedInfoSize – 1)error = GetNetworkParams(FixedInfoBuffer(0), FixedInfoSize)If error = 0 ThenCopyMemory FixedInfo, FixedInfoBuffer(0), FixedInfoSizeMsgBox “Host Name:” & FixedInfo.HostNameMsgBox “DNS Servers:” & FixedInfo.DnsServerList.IpAddresspAddrStr = FixedInfo.DnsServerList.NextDo While pAddrStr <> 0CopyMemory Buffer, ByVal pAddrStr, LenB(Buffer)MsgBox “DNS Servers:” & Buffer.IpAddresspAddrStr = Buffer.NextLoopSelect Case FixedInfo.NodeTypeCase 1MsgBox “Node type: Broadcast”Case 2MsgBox “Node type: Peer to peer”Case 4MsgBox “Node type: Mixed”Case 8MsgBox “Node type: Hybrid”Case ElseMsgBox “Unknown node type”End SelectMsgBox “NetBIOS Scope ID:” & FixedInfo.ScopeIdIf FixedInfo.EnableRouting ThenMsgBox “IP Routing Enabled “ElseMsgBox “IP Routing not enabled”End IfIf FixedInfo.EnableProxy ThenMsgBox “WINS Proxy Enabled “ElseMsgBox “WINS Proxy not Enabled “End IfIf FixedInfo.EnableDns ThenMsgBox “NetBIOS Resolution Uses DNS “ElseMsgBox “NetBIOS Resolution Does not use DNS”End IfElseMsgBox “GetNetworkParams failed with error ” & errorExit SubEnd If’ Enumerate all of the adapter specific information using the’ IP_ADAPTER_INFO structure.’ Note:IP_ADAPTER_INFO contains a linked list of adapter entries.AdapterInfoSize = 0error = GetAdaptersInfo(ByVal 0&, AdapterInfoSize)If error <> 0 ThenIf error <> ERROR_BUFFER_OVERFLOW ThenMsgBox “GetAdaptersInfo sizing failed with error ” & errorExit SubEnd IfEnd IfReDim AdapterInfoBuffer(AdapterInfoSize – 1)’ Get actual adapter informationerror = GetAdaptersInfo(AdapterInfoBuffer(0), AdapterInfoSize)If error <> 0 ThenMsgBox “GetAdaptersInfo failed with error ” & errorExit SubEnd If’ Allocate memoryCopyMemory AdapterInfo, AdapterInfoBuffer(0), AdapterInfoSizepAdapt = AdapterInfo.NextDoCopyMemory Buffer2, AdapterInfo, AdapterInfoSizeSelect Case Buffer2.TypeCase MIB_IF_TYPE_ETHERNETMsgBox “Adapter name: Ethernet adapter “Case MIB_IF_TYPE_TOKENRINGMsgBox “Adapter name: Token Ring adapter “Case MIB_IF_TYPE_FDDIMsgBox “Adapter name: FDDI adapter “Case MIB_IF_TYPE_PPPMsgBox “Adapter name: PPP adapter”Case MIB_IF_TYPE_LOOPBACKMsgBox “Adapter name: Loopback adapter “Case MIB_IF_TYPE_SLIPMsgBox “Adapter name: Slip adapter “Case ElseMsgBox “Adapter name: Other adapter “End SelectMsgBox “AdapterDescription: ” & Buffer2.DescriptionPhysicalAddress = “”For i = 0 To Buffer2.AddressLength – 1PhysicalAddress = PhysicalAddress & Hex(Buffer2.Address(i))If i < Buffer2.AddressLength – 1 ThenPhysicalAddress = PhysicalAddress & “-”End IfNextMsgBox “Physical Address: ” & PhysicalAddressIf Buffer2.DhcpEnabled ThenMsgBox “DHCP Enabled “ElseMsgBox “DHCP disabled”End IfMsgBox “IP Address: ” & Buffer2.IpAddressList.IpAddressMsgBox “Subnet Mask: ” & Buffer2.IpAddressList.IpMaskpAddrStr = Buffer2.IpAddressList.NextDo While pAddrStr <> 0CopyMemory Buffer, Buffer2.IpAddressList, LenB(Buffer)MsgBox “IP Address: ” & Buffer.IpAddressMsgBox “Subnet Mask: ” & Buffer.IpMaskpAddrStr = Buffer.NextIf pAddrStr <> 0 ThenCopyMemory Buffer2.IpAddressList, ByVal pAddrStr, _LenB(Buffer2.IpAddressList)End IfLoopMsgBox “Default Gateway: ” & Buffer2.GatewayList.IpAddresspAddrStr = Buffer2.GatewayList.NextDo While pAddrStr <> 0CopyMemory Buffer, Buffer2.GatewayList, LenB(Buffer)MsgBox “IP Address: ” & Buffer.IpAddresspAddrStr = Buffer.NextIf pAddrStr <> 0 ThenCopyMemory Buffer2.GatewayList, ByVal pAddrStr, _LenB(Buffer2.GatewayList)End IfLoopMsgBox “DHCP Server: ” & Buffer2.DhcpServer.IpAddressMsgBox “Primary WINS Server: ” & _Buffer2.PrimaryWinsServer.IpAddressMsgBox “Secondary WINS Server: ” & _Buffer2.SecondaryWinsServer.IpAddress’ Display time.NewTime = DateAdd(“s”, Buffer2.LeaseObtained, #1/1/1970#)MsgBox “Lease Obtained: ” & _CStr(Format(NewTime, “dddd, mmm d hh:mm:ss yyyy”))NewTime = DateAdd(“s”, Buffer2.LeaseExpires, #1/1/1970#)MsgBox “Lease Expires :” & _CStr(Format(NewTime, “dddd, mmm d hh:mm:ss yyyy”))pAdapt = Buffer2.NextIf pAdapt <> 0 ThenCopyMemory AdapterInfo, ByVal pAdapt, AdapterInfoSizeEnd IfLoop Until pAdapt = 0End Sub Press the F5 key to run the project, click OK on each of the message boxes that are displayed, and note the results.Running this sample as compiled, EXE gives the following error message at the end:

Runtime error 10: this array is fixed and temporary locked.Running this inside IDE generates IPF at VB6.EXE at the end.

Best practice installation methods for Visual Studio 6.0

Symptoms
Many setup and installation problems can be avoided by using best practice installation methods. While these steps may not address specific problems or error messages, they significantly reduce the possibility of problems that can occur while installing products made by Microsoft or other software suppliers. Past success without using these methods is no guarantee of future success.These best practice methods are recommended for all installations, including service packs as well as non-Microsoft products. While these best practice methods might not be necessary in all cases, they reduce the potential for problems.
Resolution
Windows 95, Windows 98, or Windows Millennium Edition (Me) operating system:For more information on best practices for installing a product on the Windows 95, Windows 98, or Windows Me operating system, review the Readme file(s) that are included with the product. Clear the system temporary folder (C:\Windows\Temp).Stop all applications, particularly monitoring programs such as anti-virus programs. To do this, follow these steps: Press CTRL+ALT+DEL to open the Close Program dialog box.Select each application in turn and click End Task (with the exception of Explorer, which is the shell for Windows).NOTE: Windows Me has a System Restore feature, which returns the system to its pre-installation state if you establish a restore point prior to an installation. To establish a restore point, follow these steps: On the Start menu, point to Programs, point to Accessories, point to System Tools, and then click System Restore.Select Create a restore point and follow the prompts to create a restore point.If you need to return the system to its pre-installation state, follow these steps: On the Start menu, point to Programs, point to Accessories, point to System Tools, and then click System Restore.Select Restore my computer to an earlier time and follow the prompts.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
267952?(http://support.microsoft.com/kb/267952/EN-US/) Description of PCHealth in Windows Millennium Edition (Me)
Windows NT 4.0 or Windows 2000 operating system:For more information on best practices for installing a product on the Windows NT 4.0 or Windows 2000 operating system, review the Readme file(s) that are included with the product.Log on using the Local Administrator account (the default is Administrator). The domain that is selected must match the computer name.
NOTE: The Local Administrator account is not the same as a user account that has administrator rights. The Local Administrator account is the system account that is used to set up the operating system. Clear the system temporary folder.
For Windows NT 4.0, this folder is <system partition letter>:\Temp.
For Windows 2000, this folder is usually <system partition letter>:\Documents and Settings\<%userprofile%>\Local Settings\Temp, but it may be <system partition letter>:\Winnt\Profiles\<%userprofile>\Local Settings\Temp.Stop all unneeded services, particularly monitoring and anti-virus programs.
Additional StepsMost installations will be successful if you use just the best practice methods; however, on rare instances, additional steps may be required. If you encounter problems that are due to previous program installations or system drivers that are interacting with the installation process, see the Microsoft Knowledge Base articles that are listed in the “References” section.