473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting a tool bar button to the Windows explorer from shellextension.

Hi,

I am trying to insert a new toolbar button to the windows explorer
menu. I an able to locate the correct ToolbarWindow32 , and inserted a
button using the code snippet shown below. However the toolbar button
text is coming in jung characters. Any help will be greatly
appreciated.
Int32 iBitmap = 0;
TBBUTTON Button = new TBBUTTON();
Button.idComman d = 1000;
Button.fsState = (byte)TBSTATE.T BSTATE_ENABLED;
Button.fsStyle = (byte)(BTNS.BTN S_BUTTON | BTNS.BTNS_AUTOS IZE |
BTNS.BTNS_SHOWT EXT);
Button.dwData = 0;
Button.iString = Marshal.StringT oHGlobalUni("te st Menu\0");
Button.iBitmap = iBitmap;
Result = SetToolBarButto n(toolbarhwnd, buttoncount, ref Button);

private unsafe bool SetToolBarButto n(IntPtr hToolbar, int index, ref
TBBUTTON tbButton)
{
// One page
const int BUFFER_SIZE = 0x1000;
byte[] localBuffer = new byte[BUFFER_SIZE];
UInt32 processId = 0;
UInt32 threadId = Win32.GetWindow ThreadProcessId (hToolbar, out
processId);
IntPtr hProcess = Win32.OpenProce ss(ProcessRight s.PROCESS_ALL_A CCESS,
false, processId);
if (hProcess == IntPtr.Zero)
{
Debug.Assert(fa lse);
return false;
}

IntPtr ipRemoteBuffer = Win32.VirtualAl locEx(hProcess, IntPtr.Zero,
new UIntPtr(BUFFER_ SIZE), MemAllocationTy pe.COMMIT,
MemoryProtectio n.PAGE_READWRIT E);
if (ipRemoteBuffer == IntPtr.Zero)
{
Debug.Assert(fa lse);
return false;
}

fixed (TBBUTTON* pTBButton = &tbButton)
{
IntPtr ipTBButton = new IntPtr(pTBButto n);

// this is fixed
Int32 dwBytesWritten = 0;
IntPtr ipBytesWritten = new IntPtr(&dwBytes Written);

bool b4 = Win32.WriteProc essMemory(hProc ess,
ipRemoteBuffer,
ipTBButton,
new UIntPtr((uint)s izeof(TBBUTTON) ),
out ipBytesWritten) ;

if (!b4)
{
Debug.Assert(fa lse);
return false;
}
int chars = (int)Win32.Send Message(hToolba r, (uint)TB.TB_INS ERTBUTTON,
(IntPtr)index, ipRemoteBuffer) ;
if (chars == -1)
{
Debug.Assert(fa lse);
return false;
}
}

Win32.VirtualFr eeEx(hProcess, ipRemoteBuffer, UIntPtr.Zero,
MemAllocationTy pe.RELEASE);
Win32.CloseHand le(hProcess);

return true;
}
Dec 27 '07 #1
3 2584

"Shafiq" <sh********@gma il.comwrote in message
news:c5******** *************** ***********@e25 g2000prg.google groups.com...
Hi,

I am trying to insert a new toolbar button to the windows explorer
menu. I an able to locate the correct ToolbarWindow32 , and inserted a
button using the code snippet shown below. However the toolbar button
text is coming in jung characters. Any help will be greatly
appreciated.
Pretty sure writing shell extensions in .NET is a no-no. (Mainly because
each process can have only one CLR version loaded)
Dec 27 '07 #2
"Shafiq" <sh********@gma il.comwrote

[Shell Extension]

Not that this answers your question, but there's a big problem writing shell
extensions in .Net. The shell is a single process, and any process can only
have a single version of .Net running.

This means the shell may already be hosting a .Net 1.1. app, and your .Net
2.0 app therefore can't load. This will be very frustrating for both you and
your users.

Now with that said, what you're look for are called Band Objects, and there
are a number of toolkits out there for this. A good place to start would be:
http://www.codeproject.com/KB/cs/Ban...spx?print=true

--
Chris Mullins
Dec 27 '07 #3

"Chris Mullins [MVP - C#]" <cm******@yahoo .comwrote in message
news:Ow******** ******@TK2MSFTN GP02.phx.gbl...
"Shafiq" <sh********@gma il.comwrote

[Shell Extension]

Not that this answers your question, but there's a big problem writing
shell extensions in .Net. The shell is a single process, and any process
can only have a single version of .Net running.

This means the shell may already be hosting a .Net 1.1. app, and your .Net
2.0 app therefore can't load. This will be very frustrating for both you
and your users.
Bigger problem -- shell extensions are loaded into any program using the
common dialog boxes (at least File Open and File Save), so you have to worry
about CLR conflicts not just in the shell but with practically every single
other program on the computer.
>
Now with that said, what you're look for are called Band Objects, and
there are a number of toolkits out there for this. A good place to start
would be:
http://www.codeproject.com/KB/cs/Ban...spx?print=true

--
Chris Mullins

Dec 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3275
by: R.Marquez | last post by:
I just happened to bump into this today when I went to the Win32 Python Extensions page. I think the M.H. and his team are a bit too modest. Quote: "win32com.shell grows many more interfaces, allowing Python to operate as a nearly complete shell extension, and to interact with the shell interfaces. See the win32comext\shell\demos\server directory for examples."
0
1785
by: calfdog | last post by:
PAMIE 1.50 released!! Now with Frames suport Why wait, when you could be using this to Automate now!... It's Free!!! http://pamie.sourceforge.net ======================================================================== What is PAMIE? PAMIE stands for Python Automation module for Internet Explorer.
0
886
by: Mike Wilson | last post by:
Ok, I've been pulling my hair out for hours now :( I know I've asked this previously, but the question has now changed slightly and taken on a new direction...: I'm looking for a coded example (there are a few on the internet, but documentation is utterly horrendous!), preferably in VB.NET, or VB6 or C# (preference in this order) to allow me to create context menus dynamically at runtime when the user right clicks a file (or set of...
1
3216
by: Vandana Rola | last post by:
Hello Everyone, We are using javascript's tooltip (pop up on mouse over )function. The problem we are having is as we go scroll two or three pages deep in to the html page our tool tip /pop up gets farther away from the position where it is supposed to be. It happens to the extend that at certain point we don't see the tool tip at all. Is there a way to fix the position of the tool tip /pop up, so that no matter how deep we are in the...
0
3296
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others.
2
2027
by: Takuya Matsumoto | last post by:
Hi to all, I was wondering whether this was possible/how it was possible. I would like to add a custom button to Internet Explorer ReBar. I believe it is called ReBar or CoolBar; what I mean is the bar in the Internet Explorer where you have "Back" button. Towards the right, MSN Messenger had added a button on my computer, for example. What I would like to do is to add a button and when the user presses the
1
1615
by: Jianwei Sun | last post by:
I remember there is a tool which automatically put some simple comments on the properties and methods. I cannot find it anywhere, can somebody help me on this.
1
1613
by: Sharon | last post by:
Hi all I want to add my own button to windows explorer toolbar I found a very easy way to add a button to IE bar http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/ie_buttons.html
3
1997
by: Kannan | last post by:
Hi, I am trying to created Outloook Add-in Com in outlook using C#. I have seen this URL for developing this sample http://support.microsoft.com/?kbid=302901 When I executed this program it created new custom button called "My Custom Button" in the Outlook menu bar. But when I tried to create one more button called "Forward Mail" (code is
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.