Carl
Once again thanks - working on this for several days and getting nowhere
Here's the info you asked for. Note that I included the both GET subs in
their entirety even though this program only extracts limited info needed.
Also note
a) if I set the local machine Intranet zone permissions to "Full Trust"
program works without generating a policy exception
b)if I create a new zone with "Full Trust" and import the program "key" the
program works without generating a policy exception
Assembly - Security and Signing Follows:
'Sign the Assembly
'strong name key [MyProgram.snk] created with sn.exe. Key must reside
'in the same folder as the Visual Studio Project.
<Assembly: AssemblyKeyFileAttribute("MyProgram.snk")>
'
'Deploy the Assembly requesting FullTrust Permissions
'<Assembly: PermissionSetAttribute(SecurityAction.RequestMinimum,
Name:="FullTrust")>
The two Get subs Follow:
1)Get System Info
'Use Windows API to get User System Memory Status
Public Declare Sub GetSystemInfo Lib "kernel32.dll" (ByRef lpSystemInfo As
SYSTEM_INFO)
Public Sub Get_UserSystemInfo(ByRef ProcessorType As String)
Dim SysInfo As SYSTEM_INFO
GetSystemInfo(SysInfo)
Dim UserProcessorType As String = SysInfo.dwProcessorType.ToString
ProcessorType = UserProcessorType
End Sub
2)Get User Environment
Public Sub Get_UserEnvironment(ByRef Name As String, ByRef OSversion As
String, ByRef MachineName As String)
'PROCESS
Dim UserProcess As Process = Process.GetCurrentProcess
Dim UserProgramName As String = UserProcess.ProcessName
Dim UserPagednoMem As Long = UserProcess.NonpagedSystemMemorySize
Dim UserPagedMem As Long = UserProcess.PagedMemorySize
Dim UserPagedpeakMem As Long = UserProcess.PeakPagedMemorySize
Dim UserPagedsysMem As Long = UserProcess.PagedSystemMemorySize
Dim UserPeakMem As Long = UserProcess.PeakWorkingSet
Dim UserPrivateMem As Long = UserProcess.PrivateMemorySize
'PROCESS MODULE
'The following retrieves the name of the Program
'base module and all dll's loaded with the process
'along with their physical size and other properties.
Dim UserProcessModule As ProcessModule
Dim UserProcessModuleCollection As ProcessModuleCollection =
UserProcess.Modules
'example - get memory used by loaded dll modules
'ModuleMemorySize does not include any additional
'memory allocations that the module makes once
'it is running; it includes only the size of the
'static code and data in the module file.
'The Base Module represents the static program code.
Dim i As Integer
Dim total As Integer
For i = 0 To UserProcessModuleCollection.Count - 1
UserProcessModule = UserProcessModuleCollection(i)
total = total + UserProcessModule.ModuleMemorySize
Next
'ENVIRONMENT
'Gets the amount of physical memory mapped to
'the process context.
Dim UserMemory As Long
UserMemory = Environment.WorkingSet
'Gets the NetBIOS name of this local computer.
Dim UserMachineName As String
UserMachineName = Environment.MachineName
'Gets an OperatingSystem object that contains the
'current platform identifier and version number.
Dim UserOSVersion As String
UserOSVersion = Environment.OSVersion.ToString
'Gets the fully qualified path of the system directory
Dim UserSysDirectory As String = Environment.SystemDirectory
'Gets the user name of the person who started the
'current thread
Dim UserName As String
UserName = Environment.UserName
'Returns an array of string containing the names of
'the logical drives on the current computer, i.e.,
'"A:\", "C:\" etc
Dim UserLogicalDrives As String()
UserLogicalDrives = Environment.GetLogicalDrives
'The system special folders are folders such as Program Files,
'Programs, System, or Startup, which contain common
'information. Special folders are set by default by the
'system, or explicitly by the user, when installing a version
'of Windows.
'The GetFolderPath method uses these enumerated constants
'to designate the special folder path to retrieve
Dim UserFolder As String
UserFolder =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
'etc, etc.
'The following statement accesses network, logon
'and other user type data. Iterate as needed to
'look at the variables - 36 Total
Dim UserEnvironmentVariables As System.Collections.IDictionary
UserEnvironmentVariables = Environment.GetEnvironmentVariables()
'
'Dim de As DictionaryEntry
'For Each de In environmentVariables
' Console.WriteLine(" {0} = {1}", de.Key, de.Value)
'Next de
'return the desired data
Name = UserName
OSversion = UserOSVersion
MachineName = UserMachineName
End Sub
Regards and thanks
Mike
[quoted text, click to view] "Vagabond Software" <vagabondsw-X-@-X-gmail.com> wrote in message
news:OhjGAfSMGHA.500@TK2MSFTNGP15.phx.gbl...
> "Mike C" <MikeC@discussions.microsoft.com> wrote in message
> news:22CF49E2-ED1E-47E6-88D4-4F73C8FC22D7@microsoft.com...
>> Carl
>>
>> Thanks for the reply
>>
>> Following is a code snippet from my main sub. The policy ecxception error
>> which is picked up by the local machine arises at the first call to to
>> get
>> system and environment information.
>>
>> The CAS then throws up the debug screen locally before the "catch" can
>> activate
>>
>> code follows:
>>
>> Public Sub Main()
>> '
>> 'Allow XP style Forms to be viewed on User screen
>> Application.EnableVisualStyles()
>> Application.DoEvents()
>> '
>> 'Get the user and machine environment data
>> '
>> Try
>> Get_UserSystemInfo(USER_PROCESSOR_TYPE)
>> Get_UserEnvironment(USER_NAME, USER_OSVersion, USER_MACHINE_NAME)
>>
>> Try
>> 'Windows 2000, XP
>> Get_UserMemoryStatusEX(USER_SYSTEM_MEMORYEX,
>> USER_AVAILABLE_SYSTEM_MEMORYEX)
>>
>> Catch ex As Exception
>> ' Do Nothing if API call fails
>> End Try
>> '
>> Catch ex As System.Security.Policy.PolicyException
>> '
>> 'if the user has installed the program on one computer within a
>> network
>> 'environment and attempts to run the program from a different
>> machine
>> within
>> 'the network then the system.permissions exception will be caught
>> here.
>> '
>> MessageBox.Show(Get_Msg("50019", "", "", "", ""), _
>> "Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
>> '
>> 'terminate the program
>> End
>> '
>>
>> Catch ex As Exception
>> '
>> 'if the user has installed the program on one computer within a
>> network
>> 'environment and attempts to run the program from a different
>> machine