| How to convert _TCHAR * to string? |
|
 |
Index ‹ Visual Studio ‹ Visual Studio C++
|
- Previous
- 1
- Visual Studio C++ >> bit shiftingi wanna shift the unsigned int e.g.
from
BINARY: 0110 0000 0011 0000 1101 0000 0000 0001
into
BINARY: 1000 0000 0000 0100 0000 0000 0000 0000
with the code i << 18;
but it seems that it won't detected the leading zero during shifting ?
and wrongly give me
0100 0000 0000 0100 0000 0000 0000 0000
any solution for that ?~
- 2
- MFC >> When user trying to quit program while thread is runningHi guys, I have a memory leak problem. When I tried to quit program by click
'x' at top right corner while my ui thread and its child worker thread are
running, debugger display following messages:
The thread 0x570 has exited with code 0 (0x0).
The thread 0x574 has exited with code 0 (0x0).
Detected memory leaks!
Dumping objects ->
c:\work\MyProject\MyUIthread.cpp(396) : {717} normal block at 0x00C17CA8, 4
bytes long.
a CWinThread object at $00C17BF0, 112 bytes long
c:\work\MyProject\MyUIthread.cpp(96) : {550} normal block at 0x00C17FC0, 12
bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD
c:\work\MyProject\MyUIthread.cpp(94) : {549} normal block at 0x00C17398, 12
bytes long.
Data: < 0 > C2 30 00 00 F2 C9 00 02 D1 01 00 00
c:\work\MyProject\mainfrm.cpp(746) : {535} client block at 0x00C17E40,
subtype 0, 128 bytes long.
a CMyUIThread object at $00C17E40, 128 bytes long
Object dump complete.
The thread 0x304 has exited with code 0 (0x0).
The program c:\work\MyProject\Debug\MyProject.exe' has exited with code 0
(0x0).
In my program, ui thread is created when certain selection made from combo
box and shutdown, deleted when combo box selection. Ui thread creates one
worker thread for communication with embeded system via COM port. So in a
normal situation(combo box changed), shutdown prccedure is like this: First,
main frame PostThreadMessage(QUIT) to ui thread. Ui thread set 'running'
flag to FALSE to let worker thread exit its while(running) loop. Just before
exit, worker thread sends another QUIT packet to embeded system to power off
then PostMessage(THREAD_QUIT) to main frame. Message handler in main frame
wait for m_hThread and delete pThread. Debugger doesn't complain about this
normal shutdown and the program looks just fine when I try without debugger.
Can I neglect this situation?
Where can I insert this shutdown procedure when program is forced to quit
while threads running?
Any suggestion appreciated. Cheers
- 3
- MFC >> questin about enum all threads of a processHi all:
I know I can enum the threads of a process using toolhelper lib in win2k
or win9x. but the lib is not availble at Winnt. instead of toolhelper,
microsoft supply the performance data library, but the data struct is too
complex. Can I have another way to get all threads handle of a process?
Thank advance.
sincecely
- 4
- Visual Basic [VB] >> Fill Combobox with DVI would like to fill a combobox with the values of one
column of the dataview I am using. When I set it up the
way I expect it would be, I get every row in the combobox
says: System.Data.DataRowView
If I click on one, it navigates to the right place. Any
idea how I would get the System.Data.DataRowView to show
the actual values in the column?
Thanks
- 5
- Visual Basic [VB] >> Share source files among projects?Is it possible to share a single source file among two or more Projects in a
Solution?
I'm not talking about a DLL, just a .vb file that might contain a class or
module with common code to be compiled into each project. That way this
code can be updated once instead of makiing duplicate changes to identical
code within each project.
I have tried putting the source in a common folder, then using Add Existing
Item to add it to each project, but that creates a separate copy of the file
in each project folder. Then I'm back to keeping changes syncronized
manually.
I have been searching VB.NET help and newsgroups, but either this can't be
done or I am asking the wrong questions.
thanks
Dick
- 6
- MFC >> Debug Assertion FailedFirst the problem, then I'll attempt to post all of the info I think may be pertinent. I get the following message when I try to register a dll on a machine other than the one I built it on
Debug Assertion Failed
Program: C:\B7\DV7333\bin32\REGSVR32.EX
File: olelink.cp
Line: 29
When developing, it builds fine and I am able to register it on the development machine
This is an MFC dll which implements the class wizard generated: DllGetClassObject, DllCanUnloadNow, and DllRegisterServer functions
I have used depends.exe on the target machine and all it's dependcies are accounted for
I have another VB created dll that provides a few classes that are used in this problem dll. I access those via the following statement: #import "vbdll.dll" no_namespac
This stuff I dont really understand, but it appears to work. I do receive the following warning message during the mfc dll build
d:\program files\microsoft visual studio\vc98\include\comip.h(31) : warning C4042: '_IID' : has bad storage clas
d:\program files\microsoft visual studio\vc98\include\comip.h(57) : see reference to class template instantiation '_com_IIID<struct _vbdllObject,&struct __s_GUID _GUID_22b44757_efef_4c0b_be51_32138fe6eb04>' being compile
S:\VC++\dllProject\dllCode.cpp(328) : see reference to class template instantiation '_com_ptr_t<class _com_IIID<struct __vbdllObject,&struct __s_GUID _GUID_22b44757_efef_4c0b_be51_32138fe6eb04>>' being compile
The VB dll IS registered and IS in the path on the target machine
Thanks in advance for any insight into this problem
Jeremy
- 7
- Visual Basic [VB] >> Math.Round and SQL Server RoundI'm trying to determine the best approach for rounding in an application I'm
building. Unfortunately it appears as though SQL Server and VB.NET round in
different ways.
SQL Server
select round(123.465,2)
returns
123.470
Which I think is correct.
VB.NET
Math.Round(123.465, 2)
returns
123.46
Through online help I have read that the VB.NET way of doing it is "called
rounding to nearest, or banker's rounding."
I guess my first question is what is correct (when determining Tax or Sale
prices)?
My next question is what is the best approach for standarizing? Can I make
SQL Server act like VB.NET or VB.NET act like SQL Server?
Are there additional functions either in SQL Server or VB.NET that I am
missing?
Also it appears as if the behavior is consistent throughout the VB.NET
environment (formatcurrency and formatpercent).
There are certain parts of the applicaiton where it makes sense for SQL
Server to calculate some of the numbers and other where it makes sense for
VB.NET to.
Thanks
- 8
- MFC >> Fatloss computer programI have been using this computer program for a couple weeks now and i am very pleased with the results so far. its a software fatloss program, if your looking for a diet/weightloss plan i reccomend you check this place out first: http://fatloss9.50webs.com
- 9
- Visual Basic >> Profiler in Team Edn for S/W Dev--Any successes?I am struggling to get any useful performance data out of the profiling tool
in Visual Studio Team Edition for Software Developers.
On a simple command-line app, it reports bogus call paths in release and
release with debug info builds. With a debug build, the results are so
compromised by the overhead of calling inline functions that they are useless.
With a real-world, complex app, it either runs out of memory trying to
analyze the profile data or crashes. This is for an app that runs in 1.2
seconds normally.
It won't even run the app if you select sampling; profiling must be done
with instrumented code.
I've used MetroWerks Hierarchical Profiler, Rational Quantify and Compware
DevPartner, and all have provided useful information that have enabled me to
track down, understand and fix performance problems. Not so Visual Studio
Team Edition. Is there some trick that makes it work usefully?
Thanks,
Rich
- 10
- 11
- Visual Basic >> When using a Frame my embeded contols loose their text?I have a frame with 3 controls on it. 1 text box and 2 option controls. The
text control gets it's text from an INI file and the Option buttons get their
captions from this same ini file when the program loads. For some reason when
the program loads I loose the text and captions? I have been playing around
with the frame settings but have had no luck so I must be missing something
simple right?
- 12
- 13
- Visual Basic [VB] >> Serial Comm ProblemI wrote a program that communicate with SerialComm. In every 300
milliseconds, my program continuously send & receive data via the serial
port once the program starts.
My program is once in a while, the serial port seems corrupted because when
my data is sent, it doesn't go through the serial port, so as same to
receive process. In order to fix this, I have to close the port and reopen
the port again.
Why?!! Is there any way to fix this problem or I have to check for
corruption port, then I reopen the serial port again?
Thanks!
Michael
- 14
- Mcse >> OT: Beta 2Beta 2 is here!!!
Windows Server 2007 beta 2
Office 2007 beta 2
Vista beta 2
All should be available to anyone, I think!
And yeah, Virtual Server R2 SP1 beta 1, too!
What a great time to be a nerd!
- 15
- Visual Basic [VB] >> ADO in VB.NETHi
I want to apply ADO object in VB.NET. Can I bind the textbox, editmask,
combo box and grid control to the ADO recordset?
Any sample would be appreciated.
Thanks...Douglas
|
| Author |
Message |
wamax

|
Posted: Wed Oct 18 15:10:38 CDT 2006 |
Top |
Visual Studio C++ >> How to convert _TCHAR * to string?
I need to check command line parameter
if (argv[1] == option) .... // option is a string variable
And argv is defined as _TCHAR* argv[] by MSVS wizard.
The code don't work and it's very hard to convert argv[1] to string.
Visual Studio339
|
| |
|
| |
 |
Doug

|
Posted: Wed Oct 18 15:10:38 CDT 2006 |
Top |
Visual Studio C++ >> How to convert _TCHAR * to string?
On Wed, 18 Oct 2006 11:48:01 -0700, nkw <EMail@HideDomain.com>
wrote:
>I need to check command line parameter
>if (argv[1] == option) .... // option is a string variable
>
>And argv is defined as _TCHAR* argv[] by MSVS wizard.
>The code don't work and it's very hard to convert argv[1] to string.
What's the type of "option"? I'm going to assume it's std::string, and if
so, the variable "option" needs to be a TCHAR-based string, e.g. a tstring
defined as below:
typedef std::basic_string<TCHAR> tstring;
--
Doug Harrison
Visual C++ MVP
|
| |
|
| |
 |
Ulrich

|
Posted: Thu Oct 19 02:15:53 CDT 2006 |
Top |
Visual Studio C++ >> How to convert _TCHAR * to string?
nkw wrote:
> I need to check command line parameter
> if (argv[1] == option) .... // option is a string variable
>
> And argv is defined as _TCHAR* argv[] by MSVS wizard.
> The code don't work and it's very hard to convert argv[1] to string.
You can replace the non-standard tmain(int, TCHAR**) with a standard
main(int, char**) and then it works. Another alternative is to use a
TCHAR-based string all the way through. Yet another one is to convert
strings accordingly and compare then.
Uli
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio ‹ Visual Studio C++ |
- Next
- 1
- Visual Studio C++ >> Problem with covariant return typesThe following code won't compile (error C2555: 'B::f': overriding virtual
function return type differs and is not covariant from 'A::f') unless I
moved the definitions of X and Y to before the definitions of A and B
respectively. Now I can understand that the compiler doesn't know that Y is
derived from X when parsing B but at the very least this is a very confusing
error message and I'm not sure it shouldn't be accepted.
Rob.
class X;
class A
{
public:
virtual X* f () const = 0;
};
class X
{
public:
};
class Y;
class B : public A
{
public:
virtual Y* f () const;
};
class Y : public X
{
public:
};
- 2
- Visual Studio C++ >> Simple question about dllimportI've got a h file for a usb device that has definitions of function exported
from a dll. An example would be (with #defines translated):
extern "C" __declspec(dllimport) int __stdcall FT_Open(int deviceNumber, int
*pHandle);
but where is the actual dll filename specified so my program knows where to
find it?
Thanks,
Michael
- 3
- Visual Basic >> Icon size problemHello,
My program's frmAbout has an icon. The ico file has the same icon in two
sizes, 16 x 16 and 32 x 32 pixels. I don't want the smaller one to be
displayed to users. So, the size should be 32 x 32 pixels.
Anyway, on some computers the icon will be displayed in size 16 x 16
pixels. How could I prevent this?
The ico file is dislayed in picIcon which is a PictureBox element. Its
ScaleMode is "Pixel", AutoDraw is "False", and AutoSize is "False".
The ScaleMode value of frmAbout is "Twip".
What should I do?
Thanks,
Mika
- 4
- Visual Basic >> ErrorsDear All,
Does anyone know of a third party tool that can add error handling code to
all subs/functions in a class or module to a specified format which then can
be customised to deal with the errors likely to be raised at the code?
I have been neglectful in adding error handling code and comments as I go as
the project has now grown and other developers are going to be using my
code. I know that it is bad practice and I have learned my lesson, but any
advice, other than its your own fault, would be most welcome. If I have to
create my own add-in for the future, can anyone suggest how I can
programatically find the start and end of a sub to add the suggested code?
Thanks again.
Alastair MacFarlane
- 5
- Visual Basic >> "Reading emails from All Public folders"Hi,
I am developing a vb application to read the latest arrived mail from
"All public folders" through outlook. This should be dynamic as the
folders increase in the "All Public folders", The program should read
the folders accordingly.
Can anyone help on this.
- 6
- Visual Basic >> compiling the entire thingHi guys...
Here's a quick query...
I have almost finished making my first project in vb...
But I am confused...as to how should i compile the entire project and make a
setup ...
i know how to make the exe files...
I searched through MSDN but couldn't get much info...
And does the setup do everything ?...I mean what about the DSNs I created in
Control Panel, and what about my entire database ?...is that also properly
installed with the setup ?...
And how do i start doing it ?....
Please help...
thanks..
anupam
anupam@anupamjain.com
- 7
- MFC >> How to implement transparent static on dialog box?I would implement a transparent static text to show
the status text of the progress on dialog box.
The background of dialog box is not default system color.
Originally, I set the bk mode of the static to transparent mode
and return a NULL_BRUSH in OnCtlColor() of dialog class.
It can fit my requirement if the static text is not changed.
However, the old text is not erased if the static text is changed.
I think I need to override some function to erase background first.
Which function do I need to override to erase the background?
or I need to implement my own static class to do so? and how?
Best Regards
Jackal Huang
- 8
- 9
- VB Scripts >> force clicking on an objectHello,
How can I force clicking on an object,
if I have the following code, and I want to do click on event_view -
How can I do that ?
Thanks :)
The code :
-------------
<input type="hidden" id="event_view" onclick = "myview" />
...
- 10
- Visual Basic [VB] >> TUTORIALS ON COMPUTER PROGRAMMINGlanguages Have the complete details regarding programming languages.
A-Z about programming languages like Java J2EE, C++, code
implementation guides and more.
http://operatingsys.blogspot.com/
Google.com is not only a search engine but also does webadvertising
through websites and blogs.
Lakhs of common people are earning hundreds of dollars through online
advertising.
It also has other products like chatting,google earth,google talk etc.
Genuine Internet jobs for all. Earn Unlimited income.visit
http://googlepromisesyou.blogspot.com/
- 11
- Visual Basic >> Calling a Macro from another workbookHi,
Yes I have read up on the different ways of doing this, but I always
come to the same problem.
In my current code I have the line
Application.Run ("T1Seed1.xls!Main")
Which works fine (it calls the "Main" macro in T1Seed2.xls). But once
the "main" macro is run, the rest of my current macro doesn't run.
Here is my code (missing some variables thata bit above, but thats
ok).
Dim ESDUFile, RootPath, WorkBookToOpen, SheetToOpen, BuildingHeight As
String
ESDUFile = Sheets("Rotate spf red").Cells(10, 9)
RootPath = ESDUFile
Do While Right(RootPath, 1) <> "\"
RootPath = Left(RootPath, Len(RootPath) - 1)
Loop
BuildingHeight = 225
SeedScale = 345
For A = 1 To NumTowers
For B = 1 To 2
SheetToOpen = "T" & A & "Seed" & B & ".xls"
WorkBookToOpen = RootPath & SheetToOpen
FileCopy ESDUFile, WorkBookToOpen
Range("C22:C57").Copy
Workbooks.Open WorkBookToOpen
Windows(SheetToOpen).Activate
Sheets("RWDI_Factors").Select
Range("H67").Select
ActiveSheet.Paste
Range("D7") = SeedScale
Range("D6") = BuildingHeight
Application.Run ("T1Seed1.xls!Main")
Sheets("Factors").Select
Application.CutCopyMode = False 'closes the clipboard with massive
amounts of data thus does not prompt to save or close
ActiveWorkbook.Close True ' false means not to save, true means to
save and close
Windows("MR_Setup_underDevelopment_profiles.xls").Activate
Next B
Next A
It works fine up until right after the Application.Run line where it
will not continue on (ie it will not select the "Factors" sheet or do
anything after).
Is there another way I can do this that will allow the original macro
to continue running after it calls the macro in the other workbook?
Any help would be appreciated.
Jack
- 12
- MFC >> ActiveX in MFCI'm trying to create an ActiveX control in MFC.
I have a library which was provided for the development of an MFC program
NOT ActiveX.
I made a sample ActiveX and included the library under
Project->Settings->Link Tab but after building the ActiveX and viewing the
control in Test Container, no methods were exposed??
Am I doing something wrong or will the library NOT work with an ActiveX???
Thanks
David
- 13
- VB Scripts >> Check for enabled NIC and execute commandHello all. I am trying to write a script with minimal vbs knowledge. I have
downloaded scriptomatic 2.0 and have made some progress but have come to a
head.
Background:
We use WSUS for all local and remote users in an NT4 domain (soon to be
migrated to AD). Remote users connect via Cisco VPN client. The clients
installs as a network device, is disable when not in use and enables when
the GUI is loaded. The detection frequency setting for WSUS runs at
intervals of 8 - 20 hours according to the documentation. This causes the
remote client to almost never check for updates.
Solution:
Write a script which checks or better still listens if the VPN is active
(objItem.ServiceName(CVirtA) and when it becomes active
(objItem.NetConnectionStatus=2) then run the command (wuauclt /detectnow).
I have the beginnings of something pasted in below which obviously doesnt
quite work unless you comment a few lines here and there, but doing that
does not give the desired result.
Can I use wsh/vbs to monitor the connection or would this need to work on a
timer?
If a timer how would that affect memory consumption on the notebook?
TIA.
' start script
On Error Resume
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("localhost")
For Each strComputer in arrComputers
WScript.Echo
WScript.Echo "======================"
WScript.Echo "Computer: "& strComputer
WScript.Echo "======================"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapter", "WQL", _
wbemFlagReturnImmediately
+ wbemFlagForwardOnly)
If objItem.ServiceName="CVirtA" And objItem.NetConnectionStatus="2" Then
' C:\Windows\SYSTEM32\wuauclt.exe /detectnow
End If
- 14
- 15
- MFC >> VC2008 dpiaware manifest?When you create a new MFC application with the wizard in VC2008 you will see
the following code in stdafx.h:
#pragma comment(linker,"/manifestdependency:\"type='win32'
name='Microsoft.Windows.Common-Controls' version='6.0.0.0'
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
What do you write in stdafx.h to add the dpiaware manifest (se below) the
same way?
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
Best regards from Gaute
|
|
|