?
Solved

Invoking PGP from Command Line...??

Posted on 2003-02-21
9
Medium Priority
?
662 Views
Last Modified: 2011-10-03
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
Comment
Question by:Regulapati
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 2

Expert Comment

by:keenez
ID: 7995658
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
 
LVL 2

Assisted Solution

by:keenez
keenez earned 300 total points
ID: 7995672
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
 

Accepted Solution

by:
eamonk earned 600 total points
ID: 8016191
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
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:Regulapati
ID: 8016717
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
 

Author Comment

by:Regulapati
ID: 8173746
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
 

Expert Comment

by:eamonk
ID: 8175152
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
 

Author Comment

by:Regulapati
ID: 8175836
Hi Eamonk,

Thanks for the reply,

I am going to try this and will let you know

Thanks again
Madhavi
0
 

Expert Comment

by:CleanupPing
ID: 8901301
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964088
Moderator, my recommended disposition is:

    Split points between: keenez and eamonk

DanRollins -- EE database cleanup volunteer
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Suggested Courses

752 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