• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 12913
  • Last Modified:

System.ComponentModel.Win32Exception: Access is denied

this is the error i get when i run the piece of code below on some machines:

System.ComponentModel.Win32Exception: Access is denied
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId,
Int32 access, Boolean throwIfExited)
   at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32
processId)
   at System.Diagnostics.Process.get_Modules()
   at System.Diagnostics.Process.get_MainModule()
   at System.Diagnostics.Process.get_ProcessName()
   at ExcelDemo.clsExcelHost..ctor() in D:\Bert Opdracht\Excel Demo for
Windows XP version\ExcelDemo\Classes\clsExcelHost.vb:line 13
   at ExcelDemo.DataBaseSelectForm.MAcroRefresh(String inputworkbook) in

the code that causes this is the following code
 Dim process1() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses()
        xlApp = CreateObject("Excel.Application")
        Dim process2() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses()
        Dim ct1 As Integer
        Dim ct2 As Integer
        Dim blnUnique As Boolean

this is the line where the error is called on        For ct1 = 0 To process1.GetUpperBound(0)
            If process2(ct1).ProcessName = "EXCEL" Then
                blnUnique = True
                For ct2 = 0 To process1.GetUpperBound(0)
                    If process1(ct2).ProcessName = "EXCEL" Then
                        If process2(ct1).Id = process1(ct2).Id Then
                            blnUnique = False
                            Exit For
                        End If
                    End If
                Next
                If blnUnique = True Then
                    procId = process2(ct1).Id
                    Exit For
                End If
            End If
If somebody can give me a clue why this is happening i would be
very thankfull

Steven Devry
0
Steven-Devry
Asked:
Steven-Devry
  • 3
1 Solution
 
UncleMidriffCommented:
I don't know if this helps, but I copied the code you posted into a sub procedure and it worked fine for me.

Could you tell us some more about the computers this is working on vs. the computers it isn't working on?
0
 
Steven-DevryAuthor Commented:
The difference between the machines in one case is the oparating system.
For the Pc having Windows XP , the code is running fine.
Fot the PC where the operating system is Windows 2000, thr code is failing.
The only difference for the rest is, that the one Pc is a laptop and the other
PC is a desktop.
But that doesn't seem relevant to me.
For the rest the user rights are both identical
0
 
UncleMidriffCommented:
Well the system that it ran fine on for me is using Windows 2000.

I'm wondering if this is related to the other access denied problem you posted about.

What is line 13 of  "D:\Bert Opdracht\Excel Demo for Windows XP version\ExcelDemo\Classes\clsExcelHost.vb?"
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now