Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, December 18, 2006

How to analyze windows installer verbose logs

Problem:
How to analyze windows installer verbose logs

Solution:
Microsoft SDK has an executable called WiLogUtl.exe in C:\program files\microsoft sdk\bin
If you try to use this with a version of windows installer higher than 2 it won't work. But if you change the version number on the very top line to 2.0.blah blah then it should work.

Keywords:analyzer installer log windows

How to trace the sql server statements that get executed when you don't have sql tools installed, specifically Sql Profiler because you are running msde or sql express.

Problem:
How to trace the sql server statements that get executed when you don't have sql tools installed, specifically Sql Profiler because you are running msde or sql express.

Solution:

1. Create this stored procedure:
CREATE proc trace_build @traceini nvarchar (245) = N'C:\ActivityTrace.ini' as
declare @traceid int, @options int, @tracefile nvarchar (245), @maxfilesize bigint
, @stoptime datetime, @minMBfree bigint, @rc int, @on bit, @cmd1 nvarchar(512)
, @events varchar(512), @columns varchar(512), @event int, @column int, @estart int, @enext int
, @cstart int, @cnext int, @le int, @lc int, @filter nvarchar(245), @filter_num int
create table #t1 ([c1] nvarchar(512))
set @cmd1 = 'bulk insert #t1 FROM '''
select @cmd1 + @traceini
exec (@cmd1 + @traceini + '''')
select @tracefile = cast(rtrim(ltrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as nvarchar (245)) from #t1 where left(c1,3) = '@tr'
select @maxfilesize = cast(rtrim(ltrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as bigint) from #t1 where left(c1,3) = '@ma'
select @stoptime = cast(rtrim(ltrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as datetime) from #t1 where left(c1,3) = '@st'
select @options = cast(rtrim(ltrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as int) from #t1 where left(c1,3) = '@op'
select @events=cast(ltrim(rtrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as nvarchar (512)) from #t1 where left(c1,3) = N'@ev'
select @columns=cast(ltrim(rtrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as nvarchar (512)) from #t1 where left(c1,3) = N'@co'
set @on = 1
set @traceid = 0
select @tracefile
SELECT @traceid = traceid FROM :: fn_trace_getinfo(0) where property = 2 and value = @tracefile
if @traceid != 0 goto finish
set @cmd1 = 'if exist ' + @tracefile + '.trc ' + 'del ' + @tracefile + '*.trc'
exec @rc = master.dbo.xp_cmdshell @cmd1, no_output
exec @rc = sp_trace_create @traceid output, @options, @tracefile, @maxfilesize, @stoptime

select @estart = 1
select @enext = charindex(',',@events,@estart)
select @cstart = 1
select @cnext = charindex(',',@columns,@cstart)
set @le = len(@events)
set @lc = len(@columns)
while @enext > 0
begin
select @event = cast(substring(@events,@estart,@enext-@estart) as int)
while @cnext > 0
begin
select @column = cast(substring(@columns,@cstart,@cnext-@cstart) as int)
exec sp_trace_setevent @traceid, @event, @column, @on
select @cstart = @cnext + 1
select @cnext = charindex(',',@columns,@cstart)
if @cnext = 0 set @cnext = @lc + 1
if @cstart >@lc set @cnext = 0
end
select @cstart = 1
select @cnext = charindex(',',@columns,@cstart)
select @estart = @enext + 1
select @enext = charindex(',',@events,@estart)
if @enext = 0 set @enext = @le + 1
if @estart > @le set @enext = 0
end
set @cmd1 = 'exec sp_trace_setfilter '
set @filter = N'none'
select @filter = cast(ltrim(rtrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as nvarchar (245))
from #t1
where cast(ltrim(rtrim(substring(c1,1,charindex('=',c1,1)-1))) as nvarchar (245)) = N'@filter1'
set @filter_num = 1
while @filter != N'none'
begin
exec (@cmd1 + @traceid + ','+@filter)
set @filter_num = @filter_num + 1
set @filter = N'none'
select @filter = cast(ltrim(rtrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as nvarchar (245)) from #t1
where cast(ltrim(rtrim(substring(c1,1,charindex('=',c1,1)-1))) as nvarchar (245)) = N'@filter' + cast(@filter_num as nvarchar(3))
select @filter
end
finish:
drop table #t1
exec sp_trace_setstatus @traceid, 1

2. Create INI file
@tracefile = C:\ActivityTrace
@maxfilesize = 50
@stoptime = 2010-12-31 12:00:00.000
@options = 2
@events = 10,11,12,13,16,17,19,33,42,43,55
@columns = 1,2,3,6,9,10,11,12,13,14,15,16,17,18,25
@filter1 = 10, 0, 7, N'SQL Profiler'

*REMEMBER TO CHANGE THE @stoptime

2. Run the trace by running the following sql:
trace_build 'c:\Trace1.ini'

3. Look at the resulting .trc file by running the following sql

select * from ::fn_trace_gettable('C:\ActivityTrace.trc', default)

See these pages for more details:
http://support.microsoft.com/kb/283790

http://support.microsoft.com/kb/283786/EN-US/

http://www.dbazine.com/sql/sql-articles/larsen6

Keywords:express msde profiler server sql trace

How do you get mfc to let you display a 256 color toolbar.

Problem:
How do you get mfc to let you display a 256 color toolbar.

Solution:

HRESULT hr = S_OK;

if(SUCCEEDED(hr))

{

hr = m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD WS_VISIBLE CBRS_TOP CBRS_GRIPPER CBRS_TOOLTIPS CBRS_FLYBY CBRS_SIZE_DYNAMIC) m_wndToolBar.LoadToolBar(IDR_MAINFRAME) ? hr : E_FAIL;

}

if(SUCCEEDED(hr))

{

CImageList *pImgList = m_wndToolBar.GetToolBarCtrl().GetImageList();
pImgList->DeleteImageList();
pImgList->Create(16, 16, ILC_COLOR8 ILC_MASK, 0, 5);
m_wndToolBar.GetToolBarCtrl().SetImageList(pImgList);
m_wndToolBar.GetToolBarCtrl().AddBitmap(5, IDR_MAINFRAME)

}

I couldn't get either of these suggestions to work.
http://www.codeguru.com/cpp/controls/toolbar/miscellaneous/article.php/c2527/
http://tanvon.wordpress.com/2006/09/19/how-to-make-256-color-toolbar/


Keywords:16 256 colors mfc toolbar

Email keeps being sent over and over, but never leaves the outlook express outbox.

Problem:
Email keeps being sent over and over, but never leaves the outlook express outbox.

Solution:
Your sent mail file has reached the 2GB maximum size. Either delete it or rename it.

Keywords:email express outlook multiple sent times

How to view the records of a wmf / emf / metafile.

Problem:
How to view the records of a wmf / emf / metafile.

Solution:
There is a tool that was distributed with MSDN that was distributed with the Visual Studio 6.0 version. The path to the file on the CD is

\SAMPLES\MSDN\TECHART\1619\emfdecode.exe

Keywords:command emf record metafile view wmf

How do you open up an executable file with the binary editor or resource editor in visual studio versions higher than visual studio 6.0

Problem:
How do you open up an executable file with the binary editor or resource editor in visual studio versions higher than visual studio 6.0

Solution:
On the file-open dialog the Open button has a little down arrow on it. Click that arrow and it gives you the various options.

Keywords:binary open resource studio visual