Register a .dll

Register a .dll

Postby TimStone » Tue May 05, 2009 11:32 pm

I need to register a .dll for my application.

From a command propmpt I would type REGSRV32 abcde.dll
In Vista, I must start the command prompt using Run As Administrator
I would like to create a call from my program that will do this process for me from within the application.

Is there a way to do this using commands inside FWH / xHarbour that will work with Vista .
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Register a .dll

Postby ukoenig » Wed May 06, 2009 12:02 am

Hello Tim,

There are some examples in the Internet, using VBScript's, to run applications as administrator.
You can execute VBSript's inside Your application with WSH ( Windows-Scripting-Host )

Save these 2 lines as : REGISTER.VBS

Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "REGSVR32.exe Application.dll", "" , "", "runas", 1


Execute the VBSCRIPT inside Your Application : Winexec('WSCRIPT.exe REGISTER.VBS')


A C-Function
---------------

SHELLEXECUTEINFO shExecInfo;

shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = _T("runas");
shExecInfo.lpFile = _T("MyAppl.exe");
shExecInfo.lpParameters = _T("-u");
shExecInfo.lpDirectory = strAppPath.text ();
shExecInfo.nShow = SW_SHOW;
shExecInfo.hInstApp = NULL;

ShellExecuteEx (&shExecInfo);


There is a post of mine in the Forum for another solution, how to use WSH.
viewtopic.php?f=3&t=14833&p=76680&hilit=scripting+host#p76680

I think it also can work, using SHELLEXECUTE directly from inside FWH.
Have a look at this link, maybe it will give You some informations.

http://forums.techarena.in/vista-admini ... 977482.htm

Best regards
Uwe :lol:
Last edited by ukoenig on Wed May 06, 2009 4:44 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Register a .dll

Postby RAMESHBABU » Wed May 06, 2009 4:13 am

Hello Mr.Tim

Look at the following thread. May be this is useful to you.

http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15102&start=45

Code: Select all  Expand view

RegisterServer( "Codejock.CommandBars.v12.1.1.ocx" )

or, if using the new version:

RegisterServer( "Codejock.CommandBars.v13.0.0.ocx" )


Code: Select all  Expand view

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

typedef LONG ( * PDLLREGISTERSERVER ) ( void );

HB_FUNC( REGISTERSERVER )
{
   HMODULE hDll = LoadLibrary( hb_parc( 1 ) );
   LONG lReturn = 0;
   
   if( hDll )
   {
      FARPROC pRegisterServer = GetProcAddress( hDll, "DllRegisterServer" );
     
      if( pRegisterServer )
         lReturn = ( ( PDLLREGISTERSERVER ) pRegisterServer )();

      FreeLibrary( hDll );
   }
   
   hb_retnl( lReturn );
}        

#pragma ENDDUMP

 
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Register a .dll

Postby anserkk » Wed May 06, 2009 6:33 am

Dear Mr.Tim,

RegisterServer() is equivalent to RegSrv32 and for me it is working fine, but in Vista you need to use the option "Run as Administrator" for the RegisterServer() to work successfully. In Vista, FWH Application will get struck at the RegisterServer(), if the "Run as Administrator" is not used.

I am also waiting for a solution to this problem.

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Register a .dll

Postby carlos vargas » Wed May 06, 2009 4:08 pm

the question is

How elevate the user to admin level in the program?????

I search in MSDN and not found a function, only a function for validate if user is admin. :-(

the ideal situation is:

Code: Select all  Expand view

#include "fivewin.ch"
function main()

   if Up2Admin( "USERADMINNAME", "OTHERDATA" )  /*this function NOT exist :-(, but ....*/
      if IsAdministrator()
         RegisterServer( "Codejock.CommandBars.v12.1.1.ocx" )
      else
         MsgInfo("User is not Administrator!")
      endif
   endif

return

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <shlobj.h>

/*BOOL IsUserAnAdmin(VOID);*/

HB_FUNC( ISADMINISTRATOR)
{
 retni( IsUserAnAdmin() );
}

HB_FUNC( REGISTERSERVER )
{
   HMODULE hDll = LoadLibrary( hb_parc( 1 ) );
   LONG lReturn = 0;
   
   if( hDll )
   {
      FARPROC pRegisterServer = GetProcAddress( hDll, "DllRegisterServer" );
     
      if( pRegisterServer )
         lReturn = ( ( PDLLREGISTERSERVER ) pRegisterServer )();

      FreeLibrary( hDll );
   }
   
   hb_retnl( lReturn );
}

#pragma ENDDUMP
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1720
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Register a .dll

Postby Antonio Linares » Wed May 06, 2009 4:53 pm

Carlos,

It seems as we have to use the Windows API functions for SIDs:

http://msdn.microsoft.com/en-us/library/aa379594(VS.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Register a .dll

Postby Antonio Linares » Wed May 06, 2009 4:57 pm

Carlos,

Here there are some functions examples to review:

http://msdn.microsoft.com/en-us/library/aa379620(VS.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Register a .dll

Postby carlos vargas » Wed May 06, 2009 9:04 pm

Antonio, Thanks you.
I Review.

Sorry for my bad english.


salu2
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1720
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests