Solved

Problem with ActiveX Control

Posted on 2002-07-19
9
146 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month7 days, 14 hours left to enroll

617 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