|
The expression rand()*10/RAND_MAX yields values between 0 and 10; when it returns 10, you're writing out of the bounds of count , hence the problem (and the reason why it only pops up for certain values of
srand(...)<code>.) <br />
<br />
Joaquín M López Muñoz<br />
Telefónica, Investigación y Desarrollo<br />
<small>Want a Boost forum in Code Project? Vote <a href="http://www.codeproject.com/script/comments/forums.asp?msg=910893&forumid=1645&mode=all&userid=111#xx910893xx">here</a>[<a href="http://www.codeproject.com/script/comments/forums.asp?msg=910893&forumid=1645&mode=all&userid=111#xx910893xx" target="_blank" title="New Window">^</a>]!</small>
|
|
|
|
|
Hi,
I am trying to tell MSSQL Server running on a remote computer on LAN to back up a database on my computer. This is done through a application written in c++.
The Idea is to back up the database on the computer where the server is located as well as on the computer running the app.
What I did before this dual requirement was presented was create a stored procedure to backup the database which took the database name and the location to be backed up to as arguments.
It works well as SQL Server backs it on the local drive specified the path.
No if I send in the network address of my computer to do the same, SQL SERVER error log tells me that operating system denied permission ( which is what will be expected ).
I send in a string as \\computername\driverletter$\path\filename.zip
How can I modify this to include the user name and passwrod so that SQL SERVER can back it up on my computer without security problems???
I have tried net use kind of syntax but it does not help.
Please help!! this is really important.
Thanks In advance.
|
|
|
|
|
The simplest way is to backup the data on the server and then copy the file to your remote pc using SHFileOperation.
John
|
|
|
|
|
that will require me to logon to the server computer from the app before attampting the copy won't it?
|
|
|
|
|
Now when I think of it the user that is logged on has to be an admin for that to work. Sorry. I guess I have worked as an admin too long...
There are several ways around this. One way around is you can execute an application as a different user. I have done this in the past. Spawn an application that transfers the file as admin.
John
|
|
|
|
|
I tried using the SHFileOperation function.
I gives me an error copying the file which says that error reading the source disk or file.
This could be related to security issue, that windows will not let me copy the file from
the server to this machine which is running the application.
So the original problem is still there. I have the usernames and passwords of both computers(the DBServer and the host running application). How do I backup the DB to host or copy the already backedup file from Server???
|
|
|
|
|
I know. Unless you are logged in on the local pc as an admin on the server pc SHFileOperation will not work. Sorry.
John
|
|
|
|
|
but I am logged in as admin !!
The problem is how to tell windows that I have admin rights to the server when using the SHFileOperation function??
|
|
|
|
|
SHFileOperation uses the rights of the logged on user . Are you sure you passed the data correctly? Is your string double null terminated?
John
|
|
|
|
|
I believe there is NT documentation that claims this is not possible. I find that hard to believe.
Anyone ever found a way to create a true system environment variable, ie, not a user var or a process var, programmatically?
Thanks.
|
|
|
|
|
:(Hi there!
I have MFC app (doc/view). In that app I have a dialog with a combobox from which I want to transfer a selected item back to the main View Class where I have a VTK(Visualization toolkit) window. basically Selecting an item in the combobox should affect the object that Im displaying in my main View
when I execute my application and select the "Dialog" and select a string in the combobox it crashes and points at the member in the View class that I want to change.
Below is the code where I change a variable in the View method SetScalars.
I was wondering if it had to do with that my dialog is modal so that it cant overwrite my view class members , because that seems to be the problem.
John, that line "alot of functions and members.... " are just VTK (vizualization toolkit) stuff.
[CODE]
void CStressesDialog::OnDropDownSelchange()
{
int idx = m_DropDown.GetCurSel();
if( idx < 0 ) return;
CWnd* pParent = GetParent();
CVtkSDIView* pView = (CVtkSDIView*)pParent;
pView = (CVtkSDIView*)pParent;
CString str;
m_DropDown.GetLBText( idx,str );
pView->SetScalars(str);
}
[/CODE]
This is what causes the crash somehow this->str_select = s; where str_select is an Cstring.
[CODE]
void CVtkSDIView::SetScalars(CString s)
{
this->str_select = s;
//VTK STUFF IN THIS FUNCTION..
this->filereader->SetScalarsName(str_select);
this->filereader->Update();
this->lut->SetTableRange(this->filereader->GetOutput()->GetScalarRange());
this->lut->Build();
this->band->GenerateValues(15,this->filereader->GetOutput()->GetScalarRange());
this->band->Update();
this->pMapper->SetScalarRange(this->filereader->GetOutput()->GetScalarRange());
this->pMapper->Update();
this->renWin->Render();
this->iren->Start();
}
[/CODE]
Thanks for your help!
/regards
peter
|
|
|
|
|
what does the warning 'unreferenced local variable' mean ? how can i get rid of it ?
|
|
|
|
|
yellowtulips wrote:
what does the warning 'unreferenced local variable' mean ?
You declared a local variable which isn't referenced (You don't make any use of it)
yellowtulips wrote:
how can i get rid of it ?
Delete the declaration of the variable or use it for anything.
MS
|
|
|
|
|
|
I have a main (parent) MDI Application that launches another MDI Application. I have altered the title bar in the parent MDI App to display active security colors(all the time). When the child MDI App gets launched, especially when it's position comes up overlapping the parent App, I notice some weirdness with the mouse probably due to confusing framework messages as a result of the always active parent MDI title bar. The mouse will disappear behind the child MDI App window because it thinks it is still owned by the parent MDI App. I have tried to intercept the OnMouseActivate in the child's View class to no success. The parent title bar must stay active per requirements. Anyone know of a way I can relinquish mouse control to this child MDI App?
Thanks!
|
|
|
|
|
i have met the problem with designing a step by step program. can anyone help me with your source code or your ideal of designing a step by step program.
|
|
|
|
|
First you'll need to explain what a "step-by-step program" is.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Dear friendz....
i would like to know hoe i can change the color of the frame of a picture control placed on a dialog box when a certain event(say OnMouseMove())takes place??
all suggestionz are welcome.....
thanx in advance...
|
|
|
|
|
Hi,
I need to remove the lower combo box in a File Dialog (I mean the one which let you choose the file type). I've tried with HideControl(cmb1) where cmb1 is the ID of that combo box, but I can't hide it (the command works with the other two Combo boxes).
Notice: I'm using VS 2003.NET, the File dialog is a bit different from the old one.
Thanks
Vilmer
|
|
|
|
|
I've not tried this exact thing, but have done something similar. Derive a class from CFileDialog . At the end of the OnInitDialog() method, post a message. In the handler for that message, call ShowWindow(..., SW_HIDE) on the control you want to hide.
If you are not using MFC, you can do the same thing using GetOpenFileName() . Just specify a hook procedure in the lpfnHook member variable. In the hook procedure, handle the WM_INITDIALOG by posting the same message as mentioned before.
Hopefully this will solve your problem, or at least point you down the right path.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I usually make my windows forms by chosing the 'Windows Application Form (.Net)' , but this time i chose 'Blank Project (.Net)' instead cus i wanted to make it from scratch. I have no problem making the worms and running it.
The problem is the IntelliSense never works anymore !? How can i fix this?
Thanks in advanced!
(PS: when making forms from blank project, how can i launch the form without launching the console as well?)
|
|
|
|
|
Hello,
For the time being, in a dialog, I have a TabCtrl with several panels.
Each of its panels has a CComboBox but they all have the same content (a list of customer names).
As this content is costly to build (lot of infos extracted from a database plus the filling of the CComboBox), I would like to build this CComboBox only once (i.e. in the OnInitDialog of the dialog containing the TabCtrl) and "share" it between all panels of the TabCtrl.
By "share", I mean : the CComboBox is displayed on each panel I click and I can select from it.
I thought to create a little daughter dialog with my CComboBox, but with the create, I am obliged to give a Parent ...
Any ideas or suggestions will be appreciated.
DD
|
|
|
|
|
this might not even work, it's just an idea. how about creating the combobox as a child of the dialog, not the tab, and see if you can use SetWindowPos() or MoveWindow() , (I can't remember which one uses &wndTopMost ) without changing the size or location, just setting the the Z-order to &wndTopMost . If this doesn't work, I hope it at least gives you another idea.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hello,
not bad this idea ... I already had the same ... )
look at my code hereunder :
m_Tab.InsertItem( 0, "Tabnbr1");
m_Tab.InsertItem( 1, "Tabnbr22");
m_pTab1 = new CTab1;
m_pTab1->Create(CTab1::IDD, &m_Tab);
m_pTab1->SetWindowPos(NULL, 4, 28 , 0, 0,SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);
m_pTab1->ShowWindow(SW_SHOW);
//
m_pTab2 = new CTab2;
m_pTab2->Create(CTab2::IDD, &m_Tab);
m_pTab2->SetWindowPos(NULL, 4, 28 , 0, 0,SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);
m_pTab2->ShowWindow(SW_HIDE);
//
m_pDialogListe = new CTestDialogListe;
m_pDialogListe->Create(CTestDialogListe::IDD, &m_Tab); // solution1
m_pDialogListe->Create(CTestDialogListe::IDD, (CWnd*) m_pTab1); // solution2
m_pDialogListe->Create(CTestDialogListe::IDD, NULL);
m_pDialogListe->SetWindowPos(NULL, 4, 28 , 0, 0,SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);
m_pDialogListe->ShowWindow(SW_SHOW);
As you can see, when we create the doughter dialog with the combo box in, we are obliged to give a parent.
If I give the Tab (solution1) as parent : ok, the combo is displayed on every panels, but is not accessable from any of the 2 panels.
If I give the panel1 (solution2) as parent : ok, the combo is displayed on panel1 and it works, but is even not displayed on panel 2. Is there a solution to make it appear and make it work on panel 2?
Thanks your your answer
DD
|
|
|
|
|
Each panel should have its own combobox. If the populating of the combobox is expensive (e.g., querying a database), you can put the data (e.g., list) in the dialog instead. Then as each panel is activated, the data can be quickly pulled from the dialog's data structure rather than from an external source. Make sense?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|