Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to use Command_ in .NET Plugin SDK

Aug
2,799
144
Using the traditional SDK with PureBasic to develope a plugin, I could...
Code:
ImportC "takecmd.lib"
  Command_(*lpszString, nReserved) As "Command"
  Evaluate_(*lpszString) As "Evaluate"
  SetEVariable_(*lpszString) As "SetEVariable"
EndImport

...and then I could do things like...

Code:
Command_("echo USAGE: Test %_year-1960",0)
Command_("set abc=123", 0)
Command_("echo " + theResult, 0)
Command_("type tmp:",0)
Command_("type " + theFile + " > tmp:",0)

How can I do this using C# and the .NET Plugin SDK for TCC?

If the anwser is contained in DotNetPluginSDK.cs,
or DotNetPluginGuide.md,
then I have missed it.

Joe
 
Thinking out loud...

Would it be possible to call into the takecmd.dll using a P/Invoke from C#?

Code:
[DllImport("takecmd.dll", EntryPoint = "Command", CharSet = CharSet.Unicode)]
static extern int Command_(string command, int reserved);

...which I believe is...
Code:
C:\...\TCMD36>exports takecmd.dll | ffind /kmt"?Command_"
        102   58 005E4370 ?Command_S@@YAHV?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@H@Z

Joe
 
Invoke-TccCommand (or its alias tcc) is the PowerShell function that calls back into Take Command to execute a TCC command. It works through this chain:

1. PowerShell side: Invoke-TccCommand calls [TakeCommand.PowerShellHost]::InvokeCommand($Command)
2. Managed bridge: InvokeCommand calls InvokeHostCallback, which invokes the native callback pointer gpfnHostCommandCallback
3. Native side: That callback (registered via TCCPowerShell_SetHostCallbacks) is where TCC processes the command string (e.g., "copy ...", "dir ...")

Usage from PowerShell:

# Full function name
Invoke-TccCommand "dir /s /b *.txt"

# Or using the alias
tcc "copy file1.txt file2.txt"

-----------------------------------

If this isn't working, let me know.
 
Yes, but I do not want to do that from PowerShell.

I want to do it from a C# code (plugin),
as I indicated in my OP.

I want to, from the C# .NET plugin;
Code:
Command_("echo USAGE: Test %_year-1960",0)
Command_("set abc=123", 0)
Command_("echo " + theResult, 0)
Command_("type tmp:",0)
Command_("type " + theFile + " > tmp:",0)

Would you please modify the Greet example plugin code that is contained in DotNetPluginGuide.md to demonstrate how to do this?

Joe
 
Back
Top