Jump to content

Registering with Windows Default program


Recommended Posts

  • Replies 45
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

To my warped sense of logic, the below says

If a file is opened using CommandLine parameter then run the _decrypt function but if the file does not have a .crypt extension run the _encrypt function.

If $CmdLine[0] > 0 Then _decrypt()
If $CmdLine[0] <> '.crypt' Then _encrypt()

Needless to say it doesn't work. No matter whether the file has .crypt extension or not it runs the _decrypt function. :huh2:

Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer.

Link to comment
Share on other sites

To my warped sense of logic, the below says

If a file is opened using CommandLine parameter then run the _decrypt function but if the file does not have a .crypt extension run the _encrypt function.

If $CmdLine[0] > 0 Then _decrypt()
If $CmdLine[0] <> '.crypt' Then _encrypt()

Needless to say it doesn't work. No matter whether the file has .crypt extension or not it runs the _decrypt function. :huh2:

If $CmdLine[0] > 0 Then
    If StringRight($CmdLine[1], 6) <> '.crypt' Then
        _encrypt()
    Else
        _decrypt()
    EndIf
EndIf
Link to comment
Share on other sites

If $CmdLine[0] > 0 Then
    If StringRight($CmdLine[1], 6) <> '.crypt' Then
        _encrypt()
    Else
        _decrypt()
    EndIf
EndIf

Thanks. So is that saying 'Count 6 places to the right of the file name, if these match .crypt then _encrypt else _decrypt'?

Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer.

Link to comment
Share on other sites

Thanks. So is that saying 'Count 6 places to the right of the file name, if these match .crypt then _encrypt else _decrypt'?

I'd say it was 'If file name ends with .crypt then encrypt else decrypt'. It's essentially a shortened version of this function I sometimes use:

Func StringEndsWith($sString, $sWith)
    Return StringRight($sString, StringLen($sWith)) = $sWith
EndFunc   ;==>StringEndsWith

In your example, _encrypt will always be run (you are using CmdLine[0]), and _decrypt will be run whenever a command line parameter is given. There would be times when both are run as well :huh2:

Link to comment
Share on other sites

I'd say it was 'If file name ends with .crypt then encrypt else decrypt'. It's essentially a shortened version of this function I sometimes use:

Func StringEndsWith($sString, $sWith)
    Return StringRight($sString, StringLen($sWith)) = $sWith
EndFunc   ;==>StringEndsWith

In your example, _encrypt will always be run (you are using CmdLine[0]), and _decrypt will be run whenever a command line parameter is given. There would be times when both are run as well :huh2:

That makes sense, thank you ;)

Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...