|
is _getdrive() helpful?
From MSDN:
int main( void )
{
int ch, drive, curdrive;
static char path[_MAX_PATH];
curdrive = _getdrive();
printf( "Available drives are:\n" );
for( drive = 1; drive <= 26; drive++ )
{
if( !_chdrive( drive ) )
{
printf( "%c:", drive + 'A' - 1 );
if( _getdcwd( drive, path, _MAX_PATH ) != NULL )
printf( " (Current directory is %s)", path );
putchar( '\n' );
}
}
_chdrive( curdrive );
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thx's _AnShUmAn_
It's working..
Now i want to add these drive name in edit box then i am geting some problem.When i am adding these drive name in edit box then first and last name is added.Middle one is skip..i am useing this code
GetDlgItemText(IDC_EDIT_DIR_TO_MONITOR,m_strDirectoryToMonitor);
if(m_strDirectoryToMonitor.Trim().IsEmpty())
{
SetDlgItemText(IDC_EDIT_DIR_TO_MONITOR,b);
}
else if(!m_strDirectoryToMonitor.Trim().IsEmpty())
{
SetDlgItemText(IDC_EDIT_DIR_TO_MONITOR2,b);
}
plz help me
|
|
|
|
|
|
JFYI- you can ignore this statement [if(!m_strDirectoryToMonitor.Trim().IsEmpty())]. It doesn't server the purpose, since if the string is empty it would be processed in the if part otherwise the else part...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Use GetLogicalDriveStrings()
|
|
|
|
|
Hello everyone,
For COM STA, there is a owner thread. My questions is, when the thread needs to communicate with components in other apartments, whether the owner thread will be blocked?
My current experiment and study results is, the STA owner thread is not blocked, it is the RPC thread (which is used for underlying communication with other apartment to send method call and retrieve method return result) will be blocked. But I am not 100% sure about this. Any comments or ideas?
thanks in advance,
George
|
|
|
|
|
I think we covered this half a year ago in this forum thread[^].
All calls in COM are blocking, i.e. the thread of the caller will be blocked until the callee returns. All methods in a COM interface returns a HRESULT that tells the caller whether the call succeeded or failed. If the call wasn't blocking the returned value would be completely bogus.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger,
I remember what we discussed before. Here is what I found from MSDN, looks like our previous conclusion, the STA owner thread will be blocked is not correct, it should be the RPC thread blocked, and STA owner thread continues to deal with message pump?
http://msdn.microsoft.com/en-us/library/ms809311.aspx[^]
Refer to section "Single-Threaded Apartments (STA)", especially figure 6, 8 and 9. Any comments?
regards,
George
|
|
|
|
|
George_George wrote: STA owner thread continues to deal with message pump
It depends on what you mean by "continues".
The call does not return to the client until the server has serviced the call.
Of course the hidden COM window processes COM related messages in order to received the response from the server and the HRESULT of the call.
Try to experiment with this:
Create a small out-of-process server with "sleep"-functionality.
Create a client that calls the "sleep" function and see what happens. Try move the client window around during the call to the server.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
George_George wrote: Since it is the STA owner thread which process the message pump, so, it should not be blocked -- if blocked, how could it retrieve message pump?
Because it's not the ordinary message pump of the application, it's a message pump provided by the COM library that filters messages. It makes the calling thread open for COM calls which makes it reentrant from a COM perspective, but it would make a window that belongs to the calling thread non-responsive. Believe me, I have it in front of me as we "speak".
George_George wrote: And it is why the STA reentry issue exists -- STA owner thread is not blocked when making an outward call.
Please refer to section "STA Reentrancy" of the following article.
Doesn't the article you linked to answer your questions?
I don't know how to explain this further, or I may have misinterpreted your question.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger,
Two more questions. The 1st question is dues to my bad English.
1.
Roger Stoltz wrote: It makes the calling thread open for COM calls which makes it reentrant from a COM perspective, but it would make a window that belongs to the calling thread non-responsive. Believe me, I have it in front of me as we "speak".
Do you mean there is something error in the reentrancy sample I posted? If it is not your points, please feel free to correct me and say some other words other than above to express your points.
2.
Roger Stoltz wrote: Doesn't the article you linked to answer your questions?
Do you mean the STA owner thread is not blocked (and continue to do message pumping), it is the RPC thread (which is used for underlying communication with other apartment to send method call and retrieve method return result) will be blocked.
regards,
George
|
|
|
|
|
Hi,
Currently, I have a form application (written in MFC). Lets call it AppsTest.exe. But I wanted to change this application (exe) into exe + COM.
What I mean is that I wanted to be able to call a COM function in my other application (eg. VB or C#) and launch a message box in my MFC application (AppsTest.exe).
I am just wondering, where to start and is there any tutorial site that I can use as reference?
Thanks for any help...
Cheers
|
|
|
|
|
Ah... found the solution. Simply convert it to Automation class
|
|
|
|
|
hey,
is there any way to set values to charachter arrays that you enter for example:
int main()
{
int a1, a2, a3, a4,...........a11, x;
cin >> a1;............cin >> a11;
char str[10][40]
for(x = 0; x < 10; x++){
gets(str[x]);
}
int "str[0]" = a1, "str[1]" = a2,.........................."str[9]" = a11;
return 0;
}
thanks
modified on Sunday, September 7, 2008 8:06 PM
|
|
|
|
|
use the pointer:
int a[10];
for(x=0;x<10;x++)
{
*str[x] = a[x];
}
You know some birds are not meant to be caged, their feathers are just too bright.
|
|
|
|
|
#include "stdafx.h"
#include "iostream"
#include "cstring"
using namespace std;
int main()
{
int x, y;
char ppl[5][80];
for(y = 0; y < 5; y++){
gets_s(ppl[y]);
}
for(x = 0; x < y; x++){
cout << ppl[x] << "\n";
}
int a[5];
for(x = 0;x < y; x++){
*ppl[x] = a[x];
}
for(x = 0;x < y; x++){
cout << a[x] << "\n";
}
return 0;
}
compile this and see what the values for each of the strings are, it doesn't work.
and how do you output the values when the variable name is the same as the name for the string,
for example if you want to display the strings showing what their values are.
|
|
|
|
|
toprogramminguy wrote: for example if you want to display the strings showing what their values are.
toprogramminguy wrote: cout << ppl[x] << "\n";
You have made it here.
toprogramminguy wrote: int a[5];
initialize it just like cin>>a[i].....
Well,if you do really want to convert from "int (like a[x])" to "char [](like ppl[x])",what you have related before.(like "str[0]" = a1,"str[1] = a2............").(The compiler does not allow you to do like this ,but you do.)
You can try this:
sprintf(str[i],"%d",a[i]);
You know some birds are not meant to be caged, their feathers are just too bright.
modified on Monday, September 8, 2008 10:25 PM
|
|
|
|
|
Thanks ill try that but can you set each of the strings be a variable name and then set a value, as opposed to setting a value to a variable name then setting the string equal to that variable name, if you can understand me and my terrible way of explaining things.
I'm only learning c++ by myself so i haven't got a clue really
thanks again
|
|
|
|
|
#include <string>
using namespace std;
string str1,str2;
str1 = "this is my first string.";
str2 = "this is my second string."
cout<<str1<<endl;
cout<<str2<<endl;
String is a class in boost c++ library,and it has many member functions
to deal with string,you can do a search about it,or find a book contains
chapter string.
You know some birds are not meant to be caged, their feathers are just too bright.
|
|
|
|
|
Cannot figure out i am doing wrong.
Program works fine, List with a check box. Initially ViewJob() is call in the On_InitDialog(). But on refreshing the data list after CheckBox check, get error saying "cannot open any more table"
//control notification
ON_NOTIFY(LVN_ITEMCHANGED, IDC_JOB_LIST, OnItemchangedLinksList)
//
void CICT_JOBS_ADMINDlg::OnItemchangedLinksList(NMHDR* pNMHDR, LRESULT* pResult)
{
CDaoDatabase onclickdb;
CDaoRecordset OnrecSet(&onclickdb);
int nItem = m_ViewJobs.GetItemCount();
CString strSQL;
onclickdb.Open("ICTNAS.mdb");
for(nItem =0 ; nItem < m_ViewJobs.GetItemCount();nItem++) {
BOOL bCheck = m_ViewJobs.GetCheck(nItem);
if( bCheck == 1)
{
CString sub = m_ViewJobs.GetItemText(nItem, 1);
OnrecSet.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Task WHERE Subject = '"+sub+"'",NULL);
OnrecSet.Edit();
OnrecSet.SetFieldValue("Task","TRUE");
OnrecSet.Update();
UpdateData(TRUE);
OnrecSet.Close();
onclickdb.Close();
ViewJobs(); *****Error With This line*****Refresh the Listbox***
}
}
*pResult = 0;
}
void CICT_JOBS_ADMINDlg::ViewJobs()
{
COleVariant var,varValue;
var.ChangeType(VT_BSTR, NULL);
CDaoDatabase vewdb;
CDaoRecordset rvewSet(&vewdb);
ListView_SetExtendedListViewStyle
(m_ViewJobs.m_hWnd, LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES);
CString subJect,date;
vewdb.Open("ICTNAS.mdb"); // Open Clients.MDB
rvewSet.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Task WHERE Task=NO ",NULL);
while(!rvewSet.IsEOF()) // Do until EOF
{
int i = 0;
rvewSet.GetFieldValue("Subject",var);
subJect = (LPCSTR)var.pbstrVal;
m_ViewJobs.InsertItem(0,"",0);
m_ViewJobs.SetItemText(0,1,subJect);
rvewSet.GetFieldValue( "Start Date", varValue );
date = COleDateTime(varValue).Format(_T("%d/%m/%y"));
m_ViewJobs.SetItemText(0,2,date);
i=i++;
rvewSet.MoveNext();
}
rvewSet.Close();
vewdb.Close();
}
any help would be nice.
Gpat
|
|
|
|
|
It could be because of the limitation of the Access Driver. BTW,What is the upper limit of the loop that is getting executed?
Regards,
Rane
|
|
|
|
|
But the proram open database once,reads data, and then closes. and when user check the checkbox, program opens database and makes changes and closes. it works fine upto here, but when refreshing the listbox ( by calling the original function ) this where the error occurs.
Gpat
|
|
|
|
|
Why are you using DAO?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi guys. I'm using a third party MFC CListCtrl inheriting class, that comes with its own CHeaderCtrl inheriting class - http://www.codeproject.com/KB/list/creportctrl.aspx[^] . It works well, but the function that updates the header of the CListCtrl to display the arrow that indicates the order of a given sort (ascending or descending) has an undesirable side effect; when called, it makes the sorted column's header appear completely flat, rather than 3D, and when the cursor rolls over the column it doesn't become highlighted. This only seems to be a problem in Windows XP.
Here's the relevant code:
void CReportCtrl::CReportHeaderCtrl::UpdateSortArrow()
{
HD_ITEM hditem;
hditem.mask = HDI_FORMAT;
VERIFY(GetItem(m_iSortColumn, &hditem));
hditem.fmt |= HDF_OWNERDRAW;
VERIFY(SetItem(m_iSortColumn, &hditem));
Invalidate();
}
If one of you could suggest a way of avoiding this, and having the arrow appear without changing the appearance of the header, that would certainly be appreciated,
Regards,
Sternocera
|
|
|
|
|