Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

XPlode 1.0x Plugin Development

- - - - -

  • Please log in to reply
35 replies to this topic

#1
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
Just a thread to ask plugin development questions - sample code, help with debugging, etc.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image


How to remove advertisement from MSFN

#2
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
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 :)
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#3
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
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 :)
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#4
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
how are the functions called?

and how are the attributes in the XML saved?
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#5
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
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.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#6
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
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.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#7
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
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?
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#8
Shotgun

Shotgun

    Advanced Member

  • Member
  • PipPipPip
  • 462 posts
@Wraith: I know you mentioned this somewhere but, what .NET version are you using?

Is it C++ or C#?

#9
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
i believe its C++.

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

EDIT::

<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....
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#10
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
@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?
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#11
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
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?
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#12
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
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:)
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#13
XtremeMaC

XtremeMaC

    MSFN SuperB

  • Member
  • PipPipPipPipPipPipPipPipPipPip
  • 5,070 posts
  • OS:Windows 7 x64
  • Country: Country Flag
@alanoll update your sig its still xpinstall :)



#14
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
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
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#15
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
Heh. I'm writing a lazy person's hotfix plugin now. :)
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#16
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
I'm sure your's will be better and done faster :) as mine would be the lazy version of your's :rolleyes:
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#17
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
hmm...time to research was error C2857 means :)
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#18
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
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.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#19
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
I'm also contemplating writing a disc-change plugin.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#20
Shotgun

Shotgun

    Advanced Member

  • Member
  • PipPipPip
  • 462 posts

@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:

#21
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
The language... it's C++ / ATL / Windows API.

Well, theoretically XPlode plugins could be done with any language that supports compiling DLL's with exported symbols, but in practice, XPlode won't allow it - the datatypes passed to the plugins are ATL datatypes - C++ only. Not really sure if ATL is supported by anything other than Visual C++, so I guess if you want to find out, go for it. It HAS to support ATL7.

The plugins are actually renamed DLL's - this is so it doesn't try loading any other *.dll files that aren't plugins.

VS.NET supports the .NET framework, but it isn't limited to creating ONLY .NET apps. Besides, .NET isn't installed during installation, so if it used it, XPlode wouldn't run.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image

#22
hevnbnd

hevnbnd

    Member

  • Member
  • PipPip
  • 268 posts
How about a plugin that a person could put a link to a specific wallpaper and have it applied or possibly even a wallpaper and style.... Just an idea.

#23
Alanoll

Alanoll

    CODE tags people, CODE tags!

  • Patrons
  • 5,496 posts
i don't think that can be done....

i think there is a function call in Windows to change teh visual style, but I"m not sure. other wise the programmer would ahve to automate keystrokes and such in the program.

as for the wallpaper, that easy enough to change. You can do it via registry entry
Welcome to the Forum! Please READ Me!!
Alright, that's it for the site for now. Now on to the next project....which could concievable replace the current site :)

#24
andre

andre
  • Member
  • 4 posts
Hi I am trying to write a plugin to conditionally execute a command:

e.g.:
<checkvideo />
<condexecute
variable="VIDEO"
value="ATI"
display='Installing ATI Catalyst Drivers'
program='%SYSTEMDRIVE%\Drivers\ATI\setup.exe'
arguments='/Q:A /R:N'
nowait='true'
hide='true'
/>
<condexecute
variable="VIDEO"
value="NVIDIA"
display='Installing NVIDIA Drivers'
program='%SYSTEMDRIVE%\Drivers\NVidia\setup.exe'
arguments='/Q:A /R:N'
nowait='true'
hide='true'
/>

My idea is to set an environment variable %VIDEO% in the checkvideo command and the condexecute command should compare the value of this variable with the desired value. If the variable contains the desired value the command would be executed.
In order to check for the video card type in the checkvideo command I found a way to do this by checking the PCI vendor Id of the display card with the devcon utility. You can see a sample output of using devcon below:

devcon.exe listclass display
Listing 2 device(s) for setup class "Display" (Display adapters).
PCI\VEN_1002&DEV_4E48&SUBSYS_4F721002&REV_00\4&B7EB302&0&0008: ALL-IN-WONDER 9800 SERIES
PCI\VEN_1002&DEV_4E68&SUBSYS_4F731002&REV_00\4&B7EB302&0&0108: ALL-IN-WONDER 9800 SERIES - Secondary

ATI have Vendor Id=1002 while NVidia Vendor Id=10DE (This is a simple checking that can be improved for other types of video cards or vendors). In order for this to work you need to have devcon.exe (you can get it from Microsoft and put it for instance in System32 directory). To get the job done I would need to run the previous command, get the command output and parse it for the vendor Id code and setting the environment variable with the correct value.

It should not be so difficult to implement condexecute by using the already existing execute source code.
I try first to create a simple checkvideo command that always set the %video% variable with a constant value but It is not working.
Another thing does anyone know how to execute the devcon.exe command and capture it's output?

Sorry for the long post...

#25
Wraith

Wraith

    Dr. Nick

  • Member
  • PipPipPipPipPipPip
  • 1,256 posts
You'll have to capture the standard console output I'd imagine.

Check the other post regarding the environment variable.
Posted ImagePosted Image
Posted ImagePosted Image
Posted ImagePosted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN