Solved

Problem with ActiveX Control

Posted on 2002-07-19
9
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

738 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