|
|
If you can modify the function (that is, you control it), you can make the return value part of the function arguments:
void getMyString(char[255]& retString)
{
memset(retString, 0, 255);
strncpy(retString, srcString, 254);
}
If you don't have access, or are not allowed to change the interface, here are some alternatives:
char buffer[255] = {0};
strncpy(buffer, myFunction(), 254);
std::string myString = myFunction();
Note that both of those can be sketchy if the returning function is allocating memory on the heap and expecting you to handle cleanup (very poor design, but not too uncommon, sadly). Just keep that in mind when dealing with this kind of thing.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: void getMyString(char[255]& retString)
That won't work.
|
|
|
|
|
You are correct. Sorry, it should have been:
void getMyString(char retString[255])
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
MSDN document says.
-------------------
Maximum Path Length
In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is D:\<256 chars>NUL.
The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix.
How do we create a file with path name more 260 characters ?.
============================================================
Lokesh
HP
|
|
|
|
|
I need to write the code to move data inputted by the user, to a SQL database... can anyone help me start this.... i'm not too familiar with visual studio yet
Cheers .. Phil
|
|
|
|
|
i want to know that CTTListBox is not in the listbox type as i want to declare a variable of this type.
when i decalare this directly or by changing CListBox type then it gives error
plz tell me how can i use this
Ashish Dogra
MCA
Noida
|
|
|
|
|
|
hi all,
i wantto create a Splitter View Please help me out.
thanks and regards,
uday.
|
|
|
|
|
Call OnCreateClient in you CMainFrame class and make the changes approprialtely.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 1,
pContext->m_pNewViewClass, CSize(0, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(200, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
SetActiveView((CScrollView*)m_wndSplitter.GetPane(0,1));
return true;
}
Hope that helps.
Fortitudine Vincimus!
|
|
|
|
|
Hi,
I want to add some code when the 'X' button on the top right of a dialog box is pressed. For example if the window size is changed, maximises/minimised we add the code in OnSize() function (WM_SIZE).
Please can you tell me how to know when the 'X ' button is pressed.
Thanks,
Tara
Fortitudine Vincimus!
|
|
|
|
|
Handle WM_CLOSE Message.
Jubin Chawda
braindrain1@rediffmail.com
-----------------------------
Come online at:-
fitiyal@yahoo.com
|
|
|
|
|
Yes, of course!! Silly of me. I did not see properly.
Thank you.
Fortitudine Vincimus!
|
|
|
|
|
yes you can useWM_CLOSE if this is your question or you want to write your button instead Close button
whitesky
|
|
|
|
|
I want a message box to appear asking the user if he wants to save his work when he closes the dialog box.
Fortitudine Vincimus!
|
|
|
|
|
int int nIndex=MessageBox("Are your sure to exit,"Question",MB_YESNO); and check return value
whitesky
|
|
|
|
|
Yes. Thank you.
Fortitudine Vincimus!
|
|
|
|
|
Hi All
I am having a problem in my application, what I am doing is:
Calling a function SaveKeys(TCHAR *) within a loop and this function save the specified registry key to a .reg file,
for this using CreateProcess( ) for calling regedit.exe from command line and WaitForSingleObject( ) function.
code looks like this
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
SaveKeys(cRegistryKey );
}<br />
<br />
void MyClass::SaveKeys(TCHAR *cRegistryKey)<br />
{<br />
STARTUPINFO StartupInfo;<br />
PROCESS_INFORMATION ProcessInformation;<br />
<br />
CreateProcess(NULL, cCommand,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|CREATE_SUSPENDED,NULL, NULL, &StartupInfo, &ProcessInformation);<br />
WaitForSingleObject( ProcessInformation.hProcess, INFINITE );<br />
<br />
}<br />
Now what is my problem is that here WaitForSingleObject( ) function is not working. and only a single reg file is created.
and when use Sleep(1000) then all the 10 reg file are created.
So please tell me that how should I overcome this problem.
Please reply
Thanks
|
|
|
|
|
|
Uninitialized STARTUPINFO structure is one of the problems of your code. It can be fixed like this:
STARTUPINFO StartupInfo = { sizeof(STARTUPINFO) };
|
|
|
|
|
In addition, it seems that the invoked regedit tools cannot work in multi-instance mode. For example, I cannot start more then one regedit application from Windows menu or command line. That's why only some of your calls work.
This probably means that you cannot do multi-threaded export using regedit tool.
|
|
|
|
|
CREATE_SUSPENDED
ResumeThread()
Kuphryn
|
|
|
|
|
iam calling the function from another class.in that function i have SetTimer(0,1000,NULL).
but it will no work.
ONTimer is not calling.
ram.
|
|
|
|
|
do you have an HANDLER ( ON_WM_TIMER ) for the timer ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
yah
void CMPEGPlayerDlg::OnPlay()
{
Onstop();
int k = m_list7.GetCurSel();
m_list7.GetText(k,m_SongName);
if(!m_SongName.IsEmpty())
{
OpenNew(m_SongName);
MessageBox(m_SongName);
}
if(m_Player.PlayerMode() == pmReady)
{
MessageBox("bye");
m_Player.Play();
}
SetTimer(0, 1000, NULL);
}
here it is working because it is in the same class
where as
void CMPEGPlayerDlg::OnPlay(CString string)
{
Onstop();
m_SongName=string;
if(!m_SongName.IsEmpty())
{
OpenNew(m_SongName);
MessageBox(m_SongName);
}
if(m_Player.PlayerMode() == pmReady)
{
MessageBox("hi");
m_Player.Play();
}
SetTimer(ID_TIMER, 1000,NULL);
}
herer not working because this fuction is calling from different class.
ram
|
|
|
|