MSFN Forum: XPlode 1.0x Plugin Development - MSFN Forum

Jump to content


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

XPlode 1.0x Plugin Development Questions, Answers? Rate Topic: -----

#1 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 04:09 PM

Just a thread to ask plugin development questions - sample code, help with debugging, etc.


#2 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 04:30 PM

Hey, this ought to be interesting.

I wonder how many are going to be posting in this thread besides me?

Well anyway, the only code I'm interested in was the execute one. If my ideas work, then i'll post the code back with the mods, but if not....I think I'll keep teh feeble ideas to myselft.

Also, in regards to the XML, are all the attributes saved, or are they just thrown out as invalid arguments. If they are thrown out, might i suggest rather keepings the arguments, but have them no use till they are needed.

Hopefully when i get home, VS will be done installing (darn multiple CDs)....

Also, don't worry about cleanign up code all that much, I'll just ignore what i don't understand :)

#3 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 05:23 PM

Well, here's the func I use to execute progs:

CString ExecuteProgram(CString program, CString arguments, bool hide, bool nowait)
{
	// Check to see we got valid inputs
	int nShow = SW_SHOW;
	if(program.CompareNoCase(_T("")) == 0)
  return _T("Invalid XML syntax - missing \'program\' attribute");
	if(hide)
  nShow = SW_HIDE;

	// Construct the logging text
	CString logtext;
	logtext.Format(_T("Running: \'%s %s\'"), program, arguments);
	if(nShow == SW_HIDE)
  logtext += _T(" (hidden)");
	WriteLog(logtext);


	// error string
	CString error = _T("");

	// set up the command to execute the program
	SHELLEXECUTEINFO ShExecInfo = {0};
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = NULL;
	ShExecInfo.lpFile = program;  
	ShExecInfo.lpParameters = arguments;	
	ShExecInfo.lpDirectory = NULL;
	ShExecInfo.nShow = nShow;
	ShExecInfo.hInstApp = NULL;	
	ShellExecuteEx(&ShExecInfo);

	// wait until the program is finished
	if(!nowait)
  WaitForSingleObject(ShExecInfo.hProcess,INFINITE);

	// get the error string if appropriate
	if(ShExecInfo.hInstApp < (HINSTANCE)32)
	{
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_FNF)
 	 error = _T("File not found.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_PNF)
 	 error = _T("Path not found.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_ACCESSDENIED)
 	 error = _T("Access denied.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_OOM)
 	 error = _T("Out of memory.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_DLLNOTFOUND)
 	 error = _T("Dynamic-link library not found.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_SHARE)
 	 error = _T("Cannot share an open file.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_ASSOCINCOMPLETE)
 	 error = _T("File association information not complete.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_DDETIMEOUT)
 	 error = _T("DDE operation timed out.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_DDEFAIL)
 	 error = _T("DDE operation failed.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_DDEBUSY)
 	 error = _T("DDE operation is busy.");
  if(ShExecInfo.hInstApp == (HINSTANCE)SE_ERR_NOASSOC)
 	 error = _T("File association not available.");
	}

	// return the possible error
	return error;
}


Have fun mutilating it :)

#4 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 05:56 PM

how are the functions called?

and how are the attributes in the XML saved?

#5 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 06:51 PM

Well, you get passed the attributes in that KeyedMap class, from the RunCommand function.

If you read the comments in the cpp file, it tells you how to access them.

If an attribute doesn't exist, the string returned will be empty.
So say you want to get an attribute of 'folder', you'd call:

bool RunCommand(...)
{
if(cmd_id == FOLDER_COMMAND)
{
CString folder = attributes[L"folder"];
if ( folder.Compare(L"") == 0 )
{
// we didn't get a folder
WriteLog(...);
return false;
}

// do something
return true;
}
return false;
}


For that execute function, I send it attributes[L"program"], attributes[L"arguments"], and whether it should be hidden, or not wait. As you can see from the functino declaration.


EDIT:
// This function is the workhorse - it performs the commands
bool _cdecl RunCommand(DWORD cmd_id, KeyedMap& attributes, CString &internaldata)
{
	/*
	*	To change the display for the current item, call 
    DISPLAY(_T("Text to display"), percentage);
	*	To add a line to the log file, call 
    WriteLog(_T("Text to log"));
	*	To retrieve a string from the configuration table, call GetString:
    CString out;
    GetString(_T("the_string"), out);
	*/

	// If you want an attribute by the name of 'stinky'
	// the value is acquired by calling:
	// CString value = attributes[_T("stinky")];
	if(cmd_id == EXECUTE_COMMAND) 
	{
  // display the text in the "display" attribute in the XML
  Display(attributes[_T("display")], -1);

  // run the program
  CString error = ExecuteProgram( 
 	 attributes[_T("program")], 
 	 attributes[_T("arguments")], 
 	 (attributes[_T("hide")].CompareNoCase(_T("true")) == 0),
 	 (attributes[_T("nowait")].CompareNoCase(_T("true")) == 0)
 	 );

  // log errors or success
  if(error.GetLength()) 
 	 WriteLog(_T("Error: ") + error);
  else
 	 WriteLog(_T("Execution succeeded"));

  return true; 
	}
	return false;
}


The execute command.

#6 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 06:51 PM

As a sidenote, if you're wondering why there's a leading 'L' on the strings, that's so they're used as UNICODE strings. XPlode will not work without them.

#7 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 07:04 PM

correct me if I'm wrong, but if i wanted to execute a program, I would HAVE to include your (or one selfwritten or wahtever) execute function as I can't call any functions built within XPlode or anyother plugins?

#8 User is offline   Shotgun 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 462
  • Joined: 07-November 03

Posted 20 February 2004 - 07:34 PM

@Wraith: I know you mentioned this somewhere but, what .NET version are you using?

Is it C++ or C#?

#9 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 08:07 PM

i believe its C++.

in the SDK, one of the files (the one for the project) says it I think

EDIT::

Quote

<VisualStudioProject
ProjectType="Visual C++"



I tried opening the vcproj file, but my VS says it can't open 7.1 files, only 7.0. How to fix this....

#10 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 08:30 PM

@Shotgun:
It has nothing to do with the .NET framework.
If you're asking what version of VS, it's VS.NET 2003.

@Alanoll:
Change the 7.1 to 7.0 in the vcproj file. :) As far as I know there's no difference in the format, just the version.

There's no easy way to call other plugins, and there's no way to call anything in XPlode, apart from the callbacks I've put in. If you've got suggestions on what kinda things you want to do with XPlode, I might be able to implement them, within reason and current code structure permitting.

The way to call other plugins would be to load the other plugin manually from yours, then call the functions. You can see the types and whatnot because your plugin function definitions would be exactly the same.
Then you'd reconstruct the arguments, and send them across to the loaded plugin.

I'd say it's a whole lot of screwing around to do something, so you might be wise writing your own functions.

What were you planning to do anyways?

#11 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 08:49 PM

not a clue :)
but its always good to know if i get a sudden insperation over the weekend :rolleyes:

Is there anyway to change what is displayed in XPlode (the box that comes up) from within a plugin or just write to logs?

#12 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 08:54 PM

What do you think I wrote the Display() function for? :)

I made it only allow the plugin to change what's shown for the current item being executed, purposely. XPlode doesn't handle that line at all, apat from clearing it when the next thing is executed.

There's no real reason I want to let plugins control the whole setup. To much screwing around from item to item.

(There may be one way soon, but I'm not telling, because it could lead to abuse :rolleyes:)

#13 User is offline   XtremeMaC 

  • MSFN SuperB
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,070
  • Joined: 13-October 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 20 February 2004 - 09:02 PM

@alanoll update your sig its still xpinstall :)

#14 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 09:09 PM

mmkay, I think i figured out a way for the lazy people to do hotfixes, however I think that it will only display one item in XPlode

thanks X, atleast the link still worked :)


EDIT:: Just saw Wraith post above about the display function....good gooood

#15 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 09:15 PM

Heh. I'm writing a lazy person's hotfix plugin now. :)

#16 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 09:21 PM

I'm sure your's will be better and done faster :) as mine would be the lazy version of your's :rolleyes:

#17 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 20 February 2004 - 09:28 PM

hmm...time to research was error C2857 means :)

#18 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 09:53 PM

Hmmm. You'll have to go and change the precompiled headers to use the header file for the project. I mustn't have changed it in the debug version.

It'll probably be StdAfx.h, change it to XPlodePluginBase.h, or whatever ur plug's called.

#19 User is offline   Wraith 

  • Dr. Nick
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,256
  • Joined: 01-January 04

Posted 20 February 2004 - 09:54 PM

I'm also contemplating writing a disc-change plugin.

#20 User is offline   Shotgun 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 462
  • Joined: 07-November 03

Posted 20 February 2004 - 11:04 PM

Wraith, on Feb 20 2004, 10:30 PM, said:

@Shotgun:
It has nothing to do with the .NET framework.
If you're asking what version of VS, it's VS.NET 2003.

You answered part of my question. Which VS.NET you were using and what language is the plugin SDK done with. The SDK does not have docs that specify development requirements or if a particular language (C++, Java, C#, VB) should be used. I noticed the plugins seem to be EXE files renamed to XPD. Could I use a C++ compiler to create a plugin besides VS (e.g. Dev C++) ?

I thought the .NET part meant it supported the .NET extensions :)

Maybe you meant to say that Xplode does NOT use the .NET framework. :rolleyes:

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy