Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 161
Viewed: 2686
Added: Apr 29, 2002
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Get Entire Command Line (not just parameters) 'As it turned out, the Declare For this Function was *totally* hosed In 'Win32Api.txt -- could be why it was blowing On you. It *Is* interesting, though, 'that the behavior Is very different between NT And 98! In both environments, I 'switched To the directory of the EXE listed above, And entered... ' 'X:CodeVBW32Modules>cmdline testing 1 2 3 ' 'NT returned... ' 'cmdline testing 1 2 3 ' 'While 98 returned... ' '"X:CODEVBW32MODULESCMDLINE.EXE" testing 1 2 3

Highlight all by clicking in box
' From a UseNetPosting by Karl E Peterson

Option Explicit

Private Declare Function GetCommandLine Lib "kernel32" Alias _
"GetCommandLineW" () As Long

Private Declare Sub CopyMem Lib "kernel32" Alias _
"RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
Private Declare Function lstrlenW Lib "kernel32" _
(ByVal lpString As Long) As Long

Highlight All
Public Sub Main()
Dim lpCmdLine As Long
lpCmdLine = GetCommandLine()
MsgBox PointerToStringW(lpCmdLine), , "Command Line"
End Sub

Private Function PointerToStringW(lpStringW As Long) As String
Dim Buffer() As Byte
Dim nLen As Long

If lpStringW Then
nLen = lstrlenW(lpStringW) * 2
If nLen Then
ReDim Buffer(0 To (nLen - 1)) As Byte
CopyMem Buffer(0), ByVal lpStringW, nLen
PointerToStringW = Buffer
End If
End If
End Function;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions