Click here to Skip to main content
16,010,918 members
Home / Discussions / C#
   

C#

 
QuestionPrevent Temp File Creation Pin
#realJSOP12-Aug-08 23:49
professional#realJSOP12-Aug-08 23:49 
AnswerRe: Prevent Temp File Creation Pin
Mark Salsbery13-Aug-08 6:57
Mark Salsbery13-Aug-08 6:57 
GeneralRe: Prevent Temp File Creation Pin
#realJSOP15-Aug-08 2:31
professional#realJSOP15-Aug-08 2:31 
GeneralRe: Prevent Temp File Creation Pin
Mark Salsbery15-Aug-08 5:35
Mark Salsbery15-Aug-08 5:35 
QuestionHow can I emulate double click event to the system tray button Pin
Highwinyungoy12-Aug-08 22:50
Highwinyungoy12-Aug-08 22:50 
AnswerRe: How can I emulate double click event to the system tray button Pin
Giorgi Dalakishvili12-Aug-08 22:58
mentorGiorgi Dalakishvili12-Aug-08 22:58 
GeneralRe: How can I emulate double click event to the system tray button Pin
Highwinyungoy13-Aug-08 0:29
Highwinyungoy13-Aug-08 0:29 
GeneralRe: How can I emulate double click event to the system tray button Pin
Highwinyungoy13-Aug-08 0:34
Highwinyungoy13-Aug-08 0:34 
private unsafe bool GetTBButton( IntPtr hToolbar, int i, ref TBBUTTON tbButton, ref string text, ref IntPtr ipWindowHandle )
{
// One page
const int BUFFER_SIZE = 0x1000;

byte[] localBuffer = new byte[ BUFFER_SIZE ];

UInt32 processId = 0;
UInt32 threadId = User32.GetWindowThreadProcessId( hToolbar, out processId );

IntPtr hProcess = Kernel32.OpenProcess( ProcessRights.ALL_ACCESS, false, processId );
if ( hProcess == IntPtr.Zero ) { Debug.Assert( false ); return false; }

IntPtr ipRemoteBuffer = Kernel32.VirtualAllocEx(
hProcess,
IntPtr.Zero,
new UIntPtr( BUFFER_SIZE ),
MemAllocationType.COMMIT,
MemoryProtection.PAGE_READWRITE );

if ( ipRemoteBuffer == IntPtr.Zero ) { Debug.Assert( false ); return false; }

// TBButton
fixed ( TBBUTTON* pTBButton = & tbButton )
{
IntPtr ipTBButton = new IntPtr( pTBButton );

int b = ( int ) User32.SendMessage( hToolbar, TB.GETBUTTON, ( IntPtr ) i, ipRemoteBuffer );
if ( b == 0 ) { Debug.Assert( false ); return false; }

// this is fixed
Int32 dwBytesRead = 0;
IntPtr ipBytesRead = new IntPtr( & dwBytesRead );

bool b2 = Kernel32.ReadProcessMemory(
hProcess,
ipRemoteBuffer,
ipTBButton,
new UIntPtr( ( uint ) sizeof( TBBUTTON ) ),
ipBytesRead );

if ( ! b2 ) { Debug.Assert( false ); return false; }
}

// button text
fixed ( byte* pLocalBuffer = localBuffer )
{
IntPtr ipLocalBuffer = new IntPtr( pLocalBuffer );

int chars = ( int ) User32.SendMessage( hToolbar, TB.GETBUTTONTEXTW, ( IntPtr ) tbButton.idCommand, ipRemoteBuffer );
if ( chars == -1 ) { Debug.Assert( false ); return false; }

// this is fixed
Int32 dwBytesRead = 0;
IntPtr ipBytesRead = new IntPtr( & dwBytesRead );

bool b4 = Kernel32.ReadProcessMemory(
hProcess,
ipRemoteBuffer,
ipLocalBuffer,
new UIntPtr( BUFFER_SIZE ),
ipBytesRead );

if ( ! b4 ) { Debug.Assert( false ); return false; }

text = Marshal.PtrToStringUni( ipLocalBuffer, chars );

if ( text == " " ) text = String.Empty;
}

// window handle
fixed ( byte* pLocalBuffer = localBuffer )
{
IntPtr ipLocalBuffer = new IntPtr( pLocalBuffer );

// this is in the remote virtual memory space
IntPtr ipRemoteData = new IntPtr( tbButton.dwData );

// this is fixed
Int32 dwBytesRead = 0;
IntPtr ipBytesRead = new IntPtr( & dwBytesRead );

bool b4 = Kernel32.ReadProcessMemory(
hProcess,
ipRemoteData,
ipLocalBuffer,
new UIntPtr( 4 ),
ipBytesRead );

if ( ! b4 ) { Debug.Assert( false ); return false; }

if ( dwBytesRead != 4 ) { Debug.Assert( false ); return false; }

Int32 iWindowHandle = BitConverter.ToInt32( localBuffer, 0 );
if ( iWindowHandle == -1 ) { Debug.Assert( false ); }//return false; }

ipWindowHandle = new IntPtr( iWindowHandle );
}

Kernel32.VirtualFreeEx(
hProcess,
ipRemoteBuffer,
UIntPtr.Zero,
MemAllocationType.RELEASE );

Kernel32.CloseHandle( hProcess );

return true;
}

Here is the function used above, I got it from another article, waiting for help, thank you
GeneralRe: How can I emulate double click event to the system tray button Pin
Giorgi Dalakishvili13-Aug-08 0:34
mentorGiorgi Dalakishvili13-Aug-08 0:34 
Questione-book pdf Pin
Rzasgal12-Aug-08 21:43
Rzasgal12-Aug-08 21:43 
AnswerRe: e-book pdf PinPopular
Christian Graus12-Aug-08 22:01
protectorChristian Graus12-Aug-08 22:01 
AnswerRe: e-book pdf Pin
Rzasgal12-Aug-08 22:12
Rzasgal12-Aug-08 22:12 
GeneralRe: e-book pdf PinPopular
Christian Graus12-Aug-08 22:26
protectorChristian Graus12-Aug-08 22:26 
GeneralRe: e-book pdf Pin
Colin Angus Mackay12-Aug-08 23:46
Colin Angus Mackay12-Aug-08 23:46 
GeneralRe: e-book pdf Pin
Thomas Stockwell13-Aug-08 4:46
professionalThomas Stockwell13-Aug-08 4:46 
GeneralRe: e-book pdf Pin
Rzasgal12-Aug-08 22:24
Rzasgal12-Aug-08 22:24 
GeneralRe: e-book pdf Pin
Christian Graus12-Aug-08 22:26
protectorChristian Graus12-Aug-08 22:26 
GeneralRe: e-book pdf Pin
Rzasgal12-Aug-08 22:40
Rzasgal12-Aug-08 22:40 
GeneralRe: e-book pdf Pin
toxcct12-Aug-08 22:50
toxcct12-Aug-08 22:50 
GeneralRe: e-book pdf Pin
Christian Graus13-Aug-08 1:20
protectorChristian Graus13-Aug-08 1:20 
GeneralRe: e-book pdf Pin
Colin Angus Mackay12-Aug-08 23:52
Colin Angus Mackay12-Aug-08 23:52 
AnswerRe: e-book pdf Pin
blackjack215012-Aug-08 22:35
blackjack215012-Aug-08 22:35 
GeneralRe: e-book pdf Pin
Christian Graus12-Aug-08 22:37
protectorChristian Graus12-Aug-08 22:37 
GeneralRe: e-book pdf Pin
Rzasgal12-Aug-08 22:44
Rzasgal12-Aug-08 22:44 
GeneralRe: e-book pdf Pin
Christian Graus13-Aug-08 1:21
protectorChristian Graus13-Aug-08 1:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.