I try to use DbgPrint to print ULONG in my driver and expect it shows in the DbgView, but I failed to do so even I use so many format (like %u, %U, %lu etc). Here is my code:
ULONG Flags;
irpStack = IoGetCurrentIrpStackLocation(Irp);
Flags=(ULONG)irpStack->DeviceObject->Flags;
if(irpStack->DeviceObject->Flags !=NULL)
{
DbgPrint((“The flag is %U”,Flags));
DbgPrint((“The flag value has been printed out\n”));
}
And “The flag Value has been printed out” could show in the DbgView, but the first statement never shows up.
So Is there any wrong in my code or what format I need to use in DbgPrint?
Many Thanks. 
>
I try to use DbgPrint to print ULONG in my driver and expect it shows
in the
DbgView, but I failed to do so even I use so many format (like %u, %U,
%lu
etc). Here is my code:
ULONG Flags;
irpStack = IoGetCurrentIrpStackLocation(Irp);
Flags=(ULONG)irpStack->DeviceObject->Flags;
if(irpStack->DeviceObject->Flags !=NULL)
{
DbgPrint((“The flag is %U”,Flags));
DbgPrint((“The flag value has been printed out\n”));
}
And “The flag Value has been printed out” could show in the DbgView,
but the
first statement never shows up.
So Is there any wrong in my code or what format I need to use in
DbgPrint?
The first DbgPrint doesn’t have a newline (\n) on it. not sure if that
is the cause though.
James
> -----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Saturday, August 07, 2010 3:58 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to use DbgPrint Print ULONG type?
DbgPrint((“The flag is %U”,Flags));
DbgPrint((“The flag value has been printed out\n”));
So Is there any wrong in my code or what format I need to use
in DbgPrint?
Yes. Double parentheses. DbgPrint is C function, not a macro as KdPrint.
Try following:
DbgPrint(“The flag is %U”,Flags);
It is also better to use “\n” always or never and turn on DbgView Force
Carriage Returns option.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
Yes, I remove the brackets and it works. I didn’t even notice that …
Thanks so much, Michal and James 
Arike