|
I snagged the June 2001 SDK CD from work. I have the correct RPCDCE.H files on my hard drive at work (installed February 2001 SDK a month ago), so I'm assuming that the June 2001 CD will have the same (or better?) files.
Thanks anyway Anders.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Hi..
I'm a newbie and I have a question...
these I do at the creation of X
int X[10] = {10,20,30,40,50,60,70,80,90,100,0};
but how can I Init X later in my program.
For Example:
int X[10];
int main()
{
X[] = {10,20,30,40,50,60,70,80,90,100,0}; // whats wrong with this line?
return 0;
}
|
|
|
|
|
int main()
{
for (i = 0; i < sizeof(x) / sizeof(int); i++)
x[i] = (i+1) * 10;
}
Should do the trick,
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
|
ok so that's what you wanted to know.. i guess i thought too far ahead..
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Hard work has a future payoff. Laziness pays off now.
|
|
|
|
|
I think
int X[10]={10,20...,100,0} could also have been written as
int X[] ={10,20,..,100,0} with the compiler calculating the size of X at compile time..
Now i guess what you are asking is that why doesn't the compiler allow u to init. the way you have shown..right?
hmmm...well the answer is lurking somewhere in my head..just can't seem to put it into words..
Well it's the way the language was defined...but i don't see any harm in having a construct to initialize compound data structures at run time..
Although in your case X[] would refer to the base address of X..so the line defintely won't compile..
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Hard work has a future payoff. Laziness pays off now.
|
|
|
|
|
I have a progrma now that uses ADO to read/modify/add to and delete records from a database.
My problem is two fold. First of all I want to create the database programatically, so I import ADOX like this:
#import "c:\Program Files\Common Files\System\ADO\msadox.dll" rename ("EOF", "adoxEOF")
Then I do this to create the database
HRESULT hr = S_OK;
ADOX::_CatalogPtr m_pCatalog = NULL;
ADOX::_TablePtr m_pTable = NULL;
try
{
TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
char * pChar = new char[400];
memset(pChar, 0, 400);
sprintf(pChar, "Provider=Microsoft.JET.OLEDB.4.0;data source=%s;", (char*)DatabasePath);
m_pCatalog->Create(pChar);
delete [] pChar;
TESTHR(hr = m_pTable.CreateInstance(__uuidof(ADOX::Table)));
m_pTable->PutName("FileDatabase");
m_pTable->Columns->Append("FileName",ADOX::adVarWChar, 255);
m_pTable->Columns->Append("FilePath",ADOX::adVarWChar,255);
m_pTable->Columns->Append("FileLength",ADOX::adInteger,0);
m_pTable->Columns->Append("TimesDownloaded",ADOX::adInteger,0);
m_pTable->Columns->Append("LastModified",ADOX::adInteger,0);
m_pTable->Columns->Append("Frames",ADOX::adInteger,0);
m_pTable->Columns->Append("Seconds",ADOX::adInteger,0);
m_pTable->Columns->Append("Width",ADOX::adInteger,0);
m_pTable->Columns->Append("Height",ADOX::adInteger,0);
m_pCatalog->Tables->Append(
_variant_t((IDispatch *)m_pTable));
m_pCatalog->Tables->Refresh();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
MessageBox(NULL, bstrDescription, bstrSource, 0);
return E_FAIL;
}
catch (...)
{
MessageBox(NULL, "General Error Creating Database", "Error", 0);
return E_FAIL;
}
return S_OK;
This works up to a point - the point I try to use it. It returns no errors and creates a file but neither my code or Access 2000 can read it. The other problem is if I create an empty table ( using Access ) this fails:
m_Connection.CreateInstance(__uuidof(Connection));
CComBSTR conStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
conStr.Append(DatabasePath);
bstr_t con(conStr);
HRESULT hr = (m_Connection->Open(con, "", "", adConnectUnspecified));
As soon as I add one dummy record, it succeeds.
So for now I must ship the Access DB with the program, I cannot create it, and the DB programatically ensures a dummy (meaningless) record exists and is hidden from the user. Surely this is not how it is supposed to work, so what am I doing wrong ?
Thanks
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I have sorted out my ADO problem - apparently I need to check for a record count of 0 before calling MoveFirst();. Honestly, ADO seems designed to crash.
Anyhow, I'm still stuck on creating the DB from ADOX, and have been for some time, so any suggestions anyone has....
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
There is a great article located here:
http://codeguru.earthweb.com/controls/multiline_listbox.shtml
It has a simple CListBox with variable row height. Is there
any way of making an arbitrary row from that list viewable,
but unselectable??
Please, please, please, any response any one can give me will
be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Yes, you have to trap the incoming event, check the row and reset the current row if the one selected is an unselectable row.
Something like this should do the trick. You will need to decide what item should be selected if the one clicked is unselectable. You could just set it to the last one.
void CSelectList::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (IsUnselectable(pNMLIstView->iItem)
{
SetHtItem(iSomeotheritem)
}
*pResult = 0;
}
Ho[e this is of help,
Bill
|
|
|
|
|
You must do it in the function named OnItemSelChanging(NM_,
LRESULT *pResult), also, this is a member function of CListCtrl.
In that function, you should decide if the current item is the one you want to unselecting,and set the *pResult to 1.
///
{
if(XXXX)
{
*pResult = 1;
}
}
|
|
|
|
|
Okay, so I've got an IActiveDesktop instance, but whenever I call SetWallpaper, it sets a blank desktop instead of the image. But it's also returning S_OK. Any ideas...
Thanks,
- Mike
|
|
|
|
|
I just realize that maybe it's related to the Unicode string that SetWallpaper requires? I'm taking a LPSTR and casting it to a LPCWSTR. I can't figure out a way to test the casted string to see if it's right. How can I view a unicode string like that in something like a message box?
- Mike
|
|
|
|
|
You have to use a conversion routine to change from an LPSTR to a LPCWSTR see Technical Note 59 for more info
---
Blessed are those who can laugh at themselves, for they shall never cease to be amused
|
|
|
|
|
Hey, that fixed it! Thanks!
BTW, for anyone that wants to know, if you have a LPCSTR and want to create a LPCWSTR out of it, include afxpriv.h and do:
LPCWSTR x = A2CW(pszString);
There are other macros too, in case this isn't exactly what you're looking for.
- Mike
|
|
|
|
|
I am trying to execute some stored procedures that have parameters but I keep getting errors. Simple stored procedures with no parameters I have no problem with.
Here is my sample test code which keeps triggering user exceptions:
strProcedure = "Hojo_Test_Fun";
strQuote = strProcedure;
pCmd->CommandType = adCmdStoredProc;
pCmd->CommandText = _bstr_t(strQuote);
pCmd->Parameters->Append
(
pCmd->CreateParameter
(
_bstr_t("some_name"),
adChar,
adParamInput,
30,
_variant_t(_bstr_t("ALKFO"))
)
);
pBs = pCmd->Execute(&vNull,&vNull,adCmdUnknown);
What am I doing wrong? Help!
Hojo
|
|
|
|
|
I tend to leave the first parameter of CreateParameter as "" rather than passing some data in.
What is the error message you are getting and where is it occuring.
It might be useful if you could post the stored procedure too.
Below is the kind of code I use. I have a set of wrapper classes that I use, so this code isn't exactly what I use but covers everything I call and how I call it.
hr = m_pCommand->put_CommandText(_bstr_t("cti.CALLTRACK_ADD"));
m_pCommand->CommandType = adCmdStoredProc;
_ParameterPtr pParam;
variant_t vtCallID("CAllIDData");
pParam = m_pCommand->CreateParameter("", adChar, adParamInput, 64, vtCallID);
m_pCommand->Parameters->Append(pParam);
pParam->Value = vtCallID;
m_pCommand->Execute(NULL, NULL, adCmdStoredProc);
Michael
|
|
|
|
|
Send me your mail me direct and I'll send you a wrapper class and example.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
I am working on a project that will recieve netmeeting calls. Upon connection it will open an audiostream, and then watch the state of the INmChannelAudio object. More precisely, the INmChannelAudio object is supposed to provide an automatic callback to the INmChannelAudioNotify class, which I have written according to the samples provided by microsoft. However, for some reason it never calls back that function. Also, when I manually try to check the state of the INmChannelAudio object via the calls GetState and IsIncoming, GetState returns NM_AUDIO_TRANSFERRING once the audio object has become active, unless it has been set to pause, in which case it returns NM_AUDIO_PAUSED. IsIncoming() always returns S_FALSE, even when there is audible data coming from the speakers.
So I am led o a couple of assumptions -- Either my code to check the state is wrong, or I am connected to the object wrong. I'm almost certain my code to check the state is correct, since it changes. I am not sure about IsIncoming though, because it always returns S_FALSE. the code I have been using is
HRESULT hr;
NM_AUDIO_STATE puState;
PUSER pUser = (PUSER) PUserLocal();
INmChannelAudio * pChannel = pUser->m_pChannelAudio;
pChannel->GetState(&puState);
hr = pChannel->IsIncoming();
However, no matter what, this code doesn't really matter. I am using it to debug. My main problem is the class CAudNotify which is the INmChannelAudioNotify class. As I said before, the INmChannelAudio class, which is predefined, is supposed to call back to my CAudNotify class once they are connected. Since it does not, I assume my connect code is flawed. Here is that code:
//Class declaration
class CAudNotify : public RefCount, public CNotify, public INmChannelAudioNotify
{
public:
CAudNotify();
~CAudNotify();
// INmChannelAudioNotify
HRESULT STDMETHODCALLTYPE NmUI(CONFN uNotify);
HRESULT STDMETHODCALLTYPE MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember * pMember);
HRESULT STDMETHODCALLTYPE StateChanged(NM_AUDIO_STATE uState);
HRESULT STDMETHODCALLTYPE PropertyChanged(DWORD dwReserved);
// ICNotify methods
HRESULT STDMETHODCALLTYPE Connect (IUnknown *pUnk);
HRESULT STDMETHODCALLTYPE Disconnect(void);
// IUnknown methods
ULONG STDMETHODCALLTYPE AddRef(void);
ULONG STDMETHODCALLTYPE Release(void);
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
};
//and class code
HRESULT HookAudio(INmChannel * pChannel)
{
HRESULT hr;
CAudNotify * pNotify;
ASSERT(NULL != pChannel);
if(NULL != g_pChannelAudio)
{
g_pChannelAudio->Release();
MessageBox(NULL,"HookAudio: replacing existing g_pChannelAudio","call",MB_OK);
}
if(NULL != g_pChannelAudio)
{
g_pNotifyAud->Disconnect();
g_pNotifyAud->Release();
}
hr = pChannel->QueryInterface(IID_INmChannelAudio, (void **)&g_pChannelAudio);
if (FAILED(hr))
{
MessageBox(NULL,"HookAudio: Unable to get Audio channel","call",MB_OK);
return hr;
}
pNotify = new CAudNotify();
if(NULL == pNotify)
{
hr = E_OUTOFMEMORY;
}
else
{
hr = pNotify->Connect(g_pChannelAudio);
if(FAILED(hr))
{
MessageBox(NULL,"CAudNotify Failed" ,"call",MB_OK);
pNotify->Release();
}
else
{
MessageBox(NULL,"Audio Connection point established successfully" ,"call",MB_OK);
g_pNotifyAud = pNotify;
}
}
if(FAILED(hr))
{
MessageBox(NULL,"Audio Connection point failed" ,"call",MB_OK);
g_pChannelAudio->Release();
g_pChannelAudio = NULL;
}
return hr;
}
HRESULT STDMETHODCALLTYPE CAudNotify::QueryInterface(REFIID riid, PVOID *ppvObject)
{
HRESULT hr = S_OK;
*ppvObject = NULL;
if (riid == IID_IUnknown)
{
*ppvObject = (IUnknown *)this;
MessageBox(NULL,"CAudNotify::QueryInterface(): Returning IUnknown.","call",MB_OK);
}
else if (riid == IID_INmChannelAudioNotify)
{
*ppvObject = (/*INmChannelAudioNotify*/PVOID *)this;
MessageBox(NULL,"CChannelAudioNotify::QueryInterface(): Returning INmChannelAudioNotify.","call",MB_OK);
}
else
{
hr = E_NOINTERFACE;
*ppvObject = NULL;
MessageBox(NULL,"CAudNotify::QueryInterface(): Called on unknown interface.","call",MB_OK);
}
if (S_OK == hr)
{
AddRef();
}
return hr;
}
HRESULT CAudNotify::Connect(IUnknown *pUnk)
{
MessageBox(NULL,"CAudNotify::Connect","call",MB_OK);
return CNotify::Connect(pUnk, IID_INmChannelAudioNotify, (IUnknown *)this);
}
HRESULT STDMETHODCALLTYPE CAudNotify::MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
{
MessageBox(NULL,"MemberChanged","caudnotify",MB_OK);
PUSER pUser = PUserFromINmMember(pMember);
if(NULL!=pUser) UpdateUserChannel(pUser, (INmChannel *) (CNotify::GetPunk()), uNotify);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CAudNotify::PropertyChanged(DWORD dwReserved)
{
MessageBox(NULL,"call to caudnotify::propertychanged","call",MB_OK);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CAudNotify::StateChanged(NM_AUDIO_STATE uState)
{
//I believe this is where we'll check whether audio is incoming or outgoing and therefore whether to turn on PTT or off
MessageBox(NULL,"call to caudnotify::statechanged","call",MB_OK);
IID iid;
HRESULT hr;
INmChannelAudio *pAudioChannel;
hr = QueryInterface(iid,(void **)&pAudioChannel);
if (SUCCEEDED(hr))
if (uState == NM_AUDIO_TRANSFERRING){
MessageBox(NULL,"Transferring","duh",MB_OK);
if (pAudioChannel->IsIncoming()==S_OK){
PTTOn('A');
}
else{
PTTOn(0);
}
}
// }
return S_OK;
}
There are other bits and pieces of code in the class, but they probably have no connection.
So the problem is I don't even get that messagebox in ::MemberChanged, ::StateChanged, or ::PropertyChanged.
Please help!!
Thanks a million,
Aniel Sud
--UPDATE--
I found that the QueryInterface method is being called with several IIDs that I had not before heard of -- namely IID_IMarshall, IID_IStdMarshall, IID_IexternalConnection, and 0000001B-0000-0000-C000-000000000046. I did a search for IID_IMarshall, and came back with one newsletter that was very vague. But it did say something about requiring marshalling. What is marshalling? do I need it in this instance?
Thanks again for all the help!!
--UPDATE--
I have found out about marshalling, and I don't think I should need it in an app such as this. Moreover, I don't see anything about marshalling in the samples. Is it ok to just let these requests slide?
Thanks again!
Aniel
|
|
|
|
|
I am developing with Windows 2000 Visual C++ 6.0 SP5. I need to be able to send data over the internet to firmware connected to the internet with an always on connection. Do I use Winsock API to send the packets of TCP/IP structure?
|
|
|
|
|
Yup. You can use Winsock API for this. However, I would consider easier solutions (SOAP?).
I vote pro drink
|
|
|
|
|
Thanks for your help. What other solutions do you suggest other than SOAP?
|
|
|
|
|
Well, depends on your concrete situation. If your clients use firewalls (I guess they do), than you'd better stick with HTTP (with SOAP or without it - maybe plain HTTP POST). If they don't use firewalls, than you can use something like DCOM or CORBA.
I vote pro drink
|
|
|
|
|
Hello, the codegurus around the world.;)
If you can use HTTP, FTP or Gopher, WinInet API function is another option.
If you want to use your own Server throuth TCP/IP, WinSock (or CSocke...) is only choice.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I'm trying to capture a screen from the windows media player. It appears that they use a directx overlay for the video (not completely sure). So, if you try to capture it through the normal GDI means, all you get is the black background.
There is at least one program available that can capture it through directx, but I am trying to figure out how it is done. Can anyone tell me how to get access to the directx surface to obtain the data? EnumSurfaces appears to work only inside the same process and inside the same directdraw object. Please help!
|
|
|
|
|