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

Invoking PGP from Command Line...??

Hi all,

We are trying to use new software called PGP(for file encrypt), first we thought we can invoke the software from VB and pass parameters but we can not do that(according to the Dcumentation), So now I want to find a way to open it automatically probably from command line using bat files .... I could not find any thing from the
PGP web site If any body has any idea about this please pass it to me, It will be very helpful for me.

Thanks in advance
Madhavi
0
Regulapati
Asked:
Regulapati
  • 3
  • 2
  • 2
  • +2
2 Solutions
 
keenezCommented:
Madhavi,

Here's some code to invoke a command line and get it's return code.  This also solves the asynchronous problem.

BTW ... do not give me the points as this was copied from Microsoft's website.

Cheers,

Keenez

Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Private Type PROCESS_INFORMATION
   hProcess As Long
   hThread As Long
   dwProcessID As Long
   dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
   hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
   lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
   lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
   ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
   ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
   lpStartupInfo As STARTUPINFO, lpProcessInformation As _
   PROCESS_INFORMATION) As Long

Private Declare Function CloseHandle Lib "kernel32" _
   (ByVal hObject As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" _
   (ByVal hProcess As Long, lpExitCode As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&

Private Declare Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
   
    Dim lRet As Long, sReturned As String * 32767 ' max chars allowed in Win95
   lRet = GetPrivateProfileSectionNames(sReturned, Len(sReturned), m_FileName)


Public Function ExecCmd(cmdline$)

   Dim proc As PROCESS_INFORMATION
   Dim start As STARTUPINFO

   ' Initialize the STARTUPINFO structure:
   start.cb = Len(start)

   ' Start the shelled application:
   ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
      NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)

   ' Wait for the shelled application to finish:
      ret& = WaitForSingleObject(proc.hProcess, INFINITE)
      Call GetExitCodeProcess(proc.hProcess, ret&)
      Call CloseHandle(proc.hThread)
      Call CloseHandle(proc.hProcess)
      ExecCmd = ret&
End Function

Sub Main()
   Dim retval As Long
   retval = ExecCmd("notepad.exe")
   MsgBox "Process Finished, Exit Code " & retval
End Sub
0
 
keenezCommented:
Oh ya .... you won't need these lines in your program:

Private Declare Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
   
   Dim lRet As Long, sReturned As String * 32767 ' max chars allowed in Win95
  lRet = GetPrivateProfileSectionNames(sReturned, Len(sReturned), m_FileName)

0
 
eamonkCommented:
Hi,
I use PGP through a VB app and C++ app. I downloaded a Comm DLL that exposed all the PGP functions I needed. [Note: Check that the DLL & PGP versions are the same.)

You will find more here.
http://www.oz.net/~srheller/spgp/

Any problems let me know.

EamonK.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RegulapatiAuthor Commented:
Hi EamonK,

Thanks for the reply.
I have gone through the web site and found it very helpful but it is not fully comptable with the PGP 7.1 version.
I wanted to encrypt the file with self decrypting Archive option which is not avaible in the SPGP.


Thanks again
Madhavi.R
0
 
RegulapatiAuthor Commented:
Hi EamonK,

I am going through this site again now we want to decryp the file with out self decrypting option and I am trying to register the SPGP DLL but not sucessful, previously I register the files using regsvr32 but now I am getting an error can you tell me what to do if we want to register SPGP DLL.


Thanks
Madhavi
0
 
eamonkCommented:
Madhavi,
This is static dll, it is not an ActiveX dll. You use this by placing it in the Windows System32 directory and calling the exposed functions. The included bas file lists the function definitions that are available. It is basically like calling the Windows APIs with having to find the necessary function (as they are already listed in the .Bas file).

Hope this helps.
Eamon K.
0
 
RegulapatiAuthor Commented:
Hi Eamonk,

Thanks for the reply,

I am going to try this and will let you know

Thanks again
Madhavi
0
 
CleanupPingCommented:
Regulapati:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Split points between: keenez and eamonk

DanRollins -- EE database cleanup volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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