Solved

Problem with ActiveX Control

Posted on 2002-07-19
9
143 Views
Last Modified: 2010-05-02
I have created an ActiveX control using VB.This ActiveX Control works fine on my machine, but when i try to register the ActiveX Ocx in any other machine other than my machine, it gives me an permission denied error.But if i have logged in as the administrator of that machine then i dont face any problems.Can any one help me .
0
Comment
Question by:Swarnalakshmi
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7164465
what is this control is doing?
0
 

Author Comment

by:Swarnalakshmi
ID: 7164485
The Control is basically built over a MSFlexgrid, the columns of the FlexGrid are all database driven,for Ex the number columns the Flexgrid is fetched from the database.
It performs other functionalaties like on click of the column header it sorts the data in the column, you can hide the columns,unhide the columns and functions similiar to this.
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7164494
I suspect that the Administrator is the only user that's set up to be able to write to the Registry. This is a problem faced when user accounts are restricted to prevent the user from playing around with the PC setup. Use Control Panel / User And Passwords to see what group the user is in. Are you using "PolEdit" at all to restrict the account? If so, check in there so see how the PC is restricted.

To do this programmatically, you will have to use the "ImpersonateUser" API to temporarily log on as "Administrator" in order to register the control.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:Swarnalakshmi
ID: 7164624
We are not using 'PolEdit' and we are using "Impersonate User" and still it does not work
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7164638
OK - the only other thing I know to try is to check that the user you are "impersonating" has "Act As Part Of Operating System" set in their group. See Control Panel / Admin Tools / Local Security Policy / Local Policies / User Rights Assignment.
0
 

Author Comment

by:Swarnalakshmi
ID: 7164652
Yes the user has "Act As a Part of Operating System" set in his group, and stillthe problem persists.
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7164689
Odd, I've extracted all the bits from the module in my system that does exactly what you are trying. This only works on Windows 2000 - not on W95. I don't know about ME, XP etc.

   Declare Function LogOnUser Lib "ADVAPI32.DLL" Alias "LogonUserA" _
      (ByVal lpszUsername As String, _
      ByVal lpszDomain As String, ByVal lpszPassword As String, _
      ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, _
      phToken As Long) As Long

   Declare Function ImpersonateLoggedOnUser Lib "ADVAPI32.DLL" _
      (ByVal hToken As Long) As Long

   Declare Function RevertToSelf Lib "ADVAPI32.DLL" () As Long

  Dim mlTokenHandle       As Long

  ...begin program...
  ' Log on as a user who can update the registry
  LogOnAdmin
...some code...

  SwitchToAdmin
  ' Copy the DLL to "system32"
  FileCopy DLLPathName, DestDir & DLLName
  RegisterDLL DestDir & DLLName, False
  RevertToSelf ' Log off Admin
  ...done...

Private Sub LogOnAdmin()

   Dim Result As Boolean, Domain As String, User As String, Pass As String

   Const LOGON32_LOGON_INTERACTIVE = 2
   Const LOGON32_PROVIDER_DEFAULT = 0

   ' See if this Windows 2000 function works
   If Not CBool(RevertToSelf()) Then
      MsgBox "RevertToSelf failed. " & vbCrLf
      ' So can't do this functionality.
      Exit Sub
   End If

   User = "Auser"
   Pass = "APass" ' Case Sensitive
   Domain = "ADomain"

   If Not CBool(LogOnUser(User, Domain, Pass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, mlTokenHandle)) Then

      MsgBox "LogonUser failed: User: " & User & _
         " Domain: " & Domain & vbCrLf
      Exit Sub

   End If

End Sub

Sub SwitchToAdmin()

   If Not CBool(ImpersonateLoggedOnUser(mlTokenHandle)) Then
      MsgBox "ImpersonateLoggedUser failed." & vbCrLf
   End If

End Sub
   
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8031858
Hi Swarnalakshmi,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

Swarnalakshmi, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8095531
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question