|
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!
|
|
|
|
|
My application(.EXE) drops a buch of events into the event log for the network admin folks and other users.
In my MFC prject, I have an event message file <filename>.MC which is compiled separatedly using "mc" command line utility. After message compilation, <filename>.rc, <filename>.h and MSG00001.bin files are created by "mc". The problem is that I only know how to produce event message resource table for the evnt viewer using command line "rc"(produces <filaname>.res) and "link" step, which finally produces <filename>.dll(it will contain the table). To automate this process, I had to write a batch file, which executes all these utilites. This batch file is automatically executed in the post-build step - pretty cumbersome and boring, isn't it? This is the old Win32 way of doing things for the event viewer, and I don't particularly like it. I know that the message resource table can be easily contained within the same executable that runs my project, which will save the headache of managing two separate files, .EXE - the program, and .DLL - program's event message table.
Tried many things with .rc files and recourse.h - event viewer only recognizes messages from the .dll.
Does anyone know how to properly merge .rc and .res files within the same project to create one common resource table that will contain the prject's resources as well as its event message table.
Will be happy to digest any hints.
Thanks.
Kirill
|
|
|
|
|
Just put this line in the top of the project's .rc file...
1 11 msg00001.bin
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Help. I want to change the appearence of a check box control so that it looks flat, no background, no border, only the check appears.
The control will serve as a visual indicator and not accept input from user.
How can I do this or where should I look?
Thanks,
John
|
|
|
|
|
No background? You mean that there will be some other controls below and you want to see them?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I want the Check Box to have the same "grey" background as the Dialog which contains it -- i.e. no white background, no border around the check box.
I hope this won't be impossible or have to resort to display a bitmap.
Thanks.
Johnny
|
|
|
|
|
Derive your class from CWnd and call DrawFrameControl in OnPaint handler. DrawFrameControl can draw many UI elements, some combination of flags should give you just checkmark on standard background. No bitmap required.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
Just use a picture control with an icon - that way the background will be see-through. Then use ShowWindow(SW_SHOW / SW_HIDE) to show or hide the control.
--
Andrew.
|
|
|
|
|
Thanks.
I guess I was intimidated by using a graphic.
John
|
|
|
|
|
I have a DB in Access 2000 for which I'm trying to access from a VC++ executable using DAO. When I try to query the DB I get a dialog asking me to select a data source. If I convert the database back to a prior version which I believe is 97 format, it works fine. Might anyone know why I get the data source dialog and how I might be able to get these queries to work with a 2000 version of the DB?
Also, is it possible to convert a 2000 DB to 95? I see that Access says it can convert back to a prior but I'm wondering if this prior version is 97 and not 95.
Thanks!
"Save a tree, use Email!"
|
|
|
|
|
Check KB article Q236991.
Basically, if you're linked to MFC DLL, this should be enough to enable DAO 3.6:
AfxGetModuleState()->m_dwVersion = 0x0601;
AfxDaoInit();
There's C++ Q&A column in Jan'2000 issue of MSJ that also describes this.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi all,
Is there a way to detect if the program I'm about to launch already running?
In other words, I don't want to have more than one of the same application running. So far, I've tried EnumProcesses() and other
good stuffs but have no luck. I have a function called ProcessExist(),shown below, to detect if the specified app is currently running.
This function works if I call it from another application.
The problem is that if I call ProcessExist() inside my application, that application is ALREADY running, so ProcessExist() doesn't solve the problem.
Any help is appreciated.
Thanks
//////////////////////////////////////////////////////////
CString CMyProcess::GetProcessName(DWORD pid)
{
char ProcName[MAX_PATH]=_T("unknown");
CString Name;
HANDLE handle=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,pid);
if (handle)
{
HMODULE hMod;
DWORD needed;
if (EnumProcessModules(handle,&hMod,sizeof(hMod),&needed))
{
GetModuleBaseName(handle,hMod,ProcName,sizeof(ProcName));
Name = ProcName;
}
CloseHandle(handle);
}
return Name;
}
BOOL CMyProcess::ProcessExist(LPCTSTR lpProcName, CString &fullpathname, DWORD &pid)
{
DWORD pids[1024];
DWORD bytes_needed=0;
DWORD num_procs=0;
BOOL result = FALSE;
CString str;
if (EnumProcesses(pids,sizeof(pids),&bytes_needed))
{
num_procs = bytes_needed / sizeof(DWORD);
for (DWORD i=0; i
|
|
|
|
|
A small thing which you can do is as follows.At the beginning of the
program call a small function say init() which creates a mutex ,if that
mutex already exists that means you have another instance running.
BOOL init()
{
HANDLE mutex = CreateMutex(NULL, FALSE, "mutexname");
if(mutex == NULL)
return FALSE;
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
MessageBox("Another instance is already running.");
return FALSE;
}
return TRUE;
}
|
|
|
|
|
Thanks Rachna. I'll try that.
|
|
|
|
|
Hello
You can use this class [from MSDN]
#ifndef LimitSingleInstance_H
#define LimitSingleInstance_H
#include <windows.h>
class CLimitSingleInstance
{
protected:
DWORD m_dwLastError;
HANDLE m_hMutex;
public:
CLimitSingleInstance(TCHAR *strMutexName)
{
m_hMutex = CreateMutex(NULL, FALSE, strMutexName);
m_dwLastError = GetLastError();
}
~CLimitSingleInstance()
{
if (m_hMutex)
{
CloseHandle(m_hMutex);
m_hMutex = NULL;
}
}
BOOL IsAnotherInstanceRunning()
{
return (ERROR_ALREADY_EXISTS == m_dwLastError);
}
};
#endif
hope this helps
Nish
|
|
|
|
|
How to create a string with the identifier "IDS_STR1"?
I use the following statement to declare IDS_STR1.
#define IDS_STR1 1;
Thanks.
Maer
|
|
|
|
|
Are you talking about the string table in resources?
You can use a string table resource with CString via the LoadString method.
CString sTemp = _T("");
sTemp.LoadString(IDS_STR1)
Michael
|
|
|
|
|