How to get content plugin fields from the submenus.

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

How to get content plugin fields from the submenus.

Post by *majkinetor ! »

I want to call TC content plugin from the script.
I call ContentGetSupportedField function to get avaialble fields until function returns 0, but this only returns fields for first level of hierarchy.

For instance, plugin, filediz has fields

Short description=0
Long description=1
Version info=2

and Version info contain another set of fields. How can I get their names/indexes. I don't see this described in SDK. ( looking at version 1.4)

Code: Select all

TC_GetField(FileName, tcplug, idx=0, unit=0){
	;ft_fieldempty=-3, ft_nosuchfield=-1, ft_fileerror=-2
   	VarSetCapacity(info,512,0)
	res := DllCall(tcplug "\ContentGetValue", "str", FileName, "int", idx, "int", unit, "uint", &info, "int", 512, "int", 0)
	VarSetCapacity(info,-1)
	return info
}
thx.
Habemus majkam!
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

The submenu doesn't represent fields but units. For each field a pipe separated list of units can be returned in the "Units "parameter. This is also documented in detail in the content plug-in SDK.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Thanks.

By the way, can you tell me anything about fact that I get the list of fields for all other plugins except for ShellDetails. I tried around 15 different content plugs and they all return fileds normaly. The only one that doesn't is yours, which returns "no more fields" imediately. Does it need anything specific to run ? I tried it on 2 computers withs same results, one of which to have COMMANDER_PATH defined in machine registry.
Habemus majkam!
User avatar
franck8244
Power Member
Power Member
Posts: 704
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

2majkinetor

Shelldetails is the only plugin (IIRC) that must not be unloaded between ContentGetSupportedField and ContentGetValue.

(I had to change WdxInfoPacker for that...)
TC#88260 -
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

There are no special requirements for my plug-in except the requirements mentioned in the documentation:
http://lefteous.de/tc/docs/shelldetails/readme.htm#requirements
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

franck8244 wrote:Shelldetails is the only plugin (IIRC) that must not be unloaded between ContentGetSupportedField and ContentGetValue.
I can't for start load its fields. It returns 0 imediately.
And if I try GetValue, it also return nothing on index 0.
There are no special requirements for my plug-in except the requirements mentioned in the documentation:
I see there are no special requirements. Its funny though how your plugin is the only one so far that doesn't retun results which means code is probably good, but something else is happenin.
Habemus majkam!
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

It could be a problem with shelldetails.ini creation. Maybe the plug-in tries to store the file in an invalid location? Please check with filemon which paths are used by the plug-in.
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

majkinetor ! wrote:..., but something else is happenin.
Perhaps a missing CoInitialize() ?

Kind regards,
Holger
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

Perhaps a missing CoInitialize() ?
Well this would refer to a problem inside the plug-in not in the calling environment.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Filemon show that no ini file is read when i call the app. If I delete ini file it still work OK in TC.
Habemus majkam!
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

You are calling ContentSetDefaultParams prior to ContentGetSupportedField don't you?
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Lefteous wrote:
Perhaps a missing CoInitialize() ?
Well this would refer to a problem inside the plug-in not in the calling environment.
Who knows what will happen if the apartment isn't prepared for COM?
Kind regards,
Holger
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

Who knows what will happen if the apartment isn't prepared for COM?
CoInitialize is called inside the plug-in. There is no need to call it in the calling app.
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

If I remember well, it should be called once per every new thread.
Problems When You Call CoInitialize and CoUninitialize Repeatedly in Multithreaded Apartment
So its normally in the responsibility of the calling app to do this once.

Kind regards,
Holger
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

You are calling ContentSetDefaultParams prior to ContentGetSupportedField don't you?
This was the problem. Now I get the name of fields but units are still returned empty. Again, units are normaly returned with other plugins.


Thx.
Habemus majkam!
Post Reply