|
I am using EnumProcesses functon in my program and also GetModuleBaseName.But its gives linker error.
error is unresolved external symbol for both this function.
|
|
|
|
|
add this in the stdafx.h
#pragma comment(lib, psapi.lib)
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
#pragma comment(lib, "psapi.lib")
(Mr. Prakash forgot the quotes)
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote:
(Mr. Prakash forgot the quotes)
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hi
I am try to find one solution but failed ... i had treid hard but not seems to success...
Generally I had download one example from
http://www.codeguru.com/Cpp/W-P/dll/article.php/c3637
In this example One MDI application is in .dll with resouce and Resouce is displaying from Main application.
<cpp>
in .dll describe like this
#define CLSID_APP 0x10
// interface IDs
#define IID_MyIUnknown 0x1000
#define IID_IDocument 0x1001
// document constants
#define C_DOC_1 0x100
#define C_DOC_2 0x101
// instantiate an interface class object
BOOL __declspec(dllexport) App_GetClassObject(int nClsid,
int nId,
void** ppvObj);
struct MyIUnknown
{
MyIUnknown() { TRACE("Entering IUnknown ctor %p\n", this); }
virtual BOOL QueryInterface(int nIid, void** ppvObj) = 0;
virtual DWORD Release() = 0;
virtual DWORD AddRef() = 0;
};
struct AFX_EXT_CLASS IDocument : public MyIUnknown
{
IDocument() { TRACE("Entering IDocument ctor %p\n", this); }
virtual CDocTemplate* CreateDocTempl( CWinApp*, int ) = 0;
virtual void CreateFrame() = 0;
};
//end of .dll
<cpp>
in .exe calling like this
<cpp>
void CExeApp::InitDll()
{
VERIFY( App_GetClassObject(CLSID_APP,
IID_IDocument,
(void**)&pIDoc) );
}
///and
BOOL CExeApp::InitInstance()
{
InitDll();
pIDoc->CreateDocTempl(this, C_DOC_1);
pIDoc->CreateFrame();
}
also
int CExeApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call
// the base class
ReleaseDll();
return CWinApp::ExitInstance();
}
void CExeApp::ReleaseDll()
{
pIDoc->Release();
}
//end of .exe
<cpp>
So this code for loading resouce from .dll. ALl going great it's loading resouce from .dll and taking function also
But Now problem is there in .dll i have one dialog that i am displaying from .exe . SO in this dialog i want to call one function from Button1
so i have to copy my function into .dll but it's useless..
Basically i want to creat this function in .exe and calling from .dll like this
This will be in .dll
<cpp>
CDialog::OnButton1
{
CallFunctionFromexe()
}
<cpp>
This will be in .exe
CFormView::Void CallFunctionFromexe()
{
//my function
}
So i one who can understand all this say me how i do all this ?
This is some ascii work also
Dll has
Contain Resource------>One Dialog with Button1
| |
| |
| |
| Dialog::OnButton1()
| {
| callfunctionfromexe()
| }
|
|
|
exe has
Importing resouce-------->Function ::Void Callfunctionfromexe()
from .dll
SO when button1 will clicked so function will call from .exe using resouce .dll
Suggestion required !!!!!!!!
thanx
naresh
|
|
|
|
|
Hi
I am try to find one solution but failed ... i had treid hard but not seems to success...
Generally I had download one example from
http://www.codeguru.com/Cpp/W-P/dll/article.php/c3637
In this example One MDI application is in .dll with resouce and Resouce is displaying from Main application.
<cpp>
in .dll describe like this
#define CLSID_APP 0x10
// interface IDs
#define IID_MyIUnknown 0x1000
#define IID_IDocument 0x1001
// document constants
#define C_DOC_1 0x100
#define C_DOC_2 0x101
// instantiate an interface class object
BOOL __declspec(dllexport) App_GetClassObject(int nClsid,
int nId,
void** ppvObj);
struct MyIUnknown
{
MyIUnknown() { TRACE("Entering IUnknown ctor %p\n", this); }
virtual BOOL QueryInterface(int nIid, void** ppvObj) = 0;
virtual DWORD Release() = 0;
virtual DWORD AddRef() = 0;
};
struct AFX_EXT_CLASS IDocument : public MyIUnknown
{
IDocument() { TRACE("Entering IDocument ctor %p\n", this); }
virtual CDocTemplate* CreateDocTempl( CWinApp*, int ) = 0;
virtual void CreateFrame() = 0;
};
//end of .dll
<cpp>
in .exe calling like this
<cpp>
void CExeApp::InitDll()
{
VERIFY( App_GetClassObject(CLSID_APP,
IID_IDocument,
(void**)&pIDoc) );
}
///and
BOOL CExeApp::InitInstance()
{
InitDll();
pIDoc->CreateDocTempl(this, C_DOC_1);
pIDoc->CreateFrame();
}
also
int CExeApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call
// the base class
ReleaseDll();
return CWinApp::ExitInstance();
}
void CExeApp::ReleaseDll()
{
pIDoc->Release();
}
//end of .exe
<cpp>
So this code for loading resouce from .dll. ALl going great it's loading resouce from .dll and taking function also
But Now problem is there in .dll i have one dialog that i am displaying from .exe . SO in this dialog i want to call one function from Button1
so i have to copy my function into .dll but it's useless..
Basically i want to creat this function in .exe and calling from .dll like this
This will be in .dll
<cpp>
CDialog::OnButton1
{
CallFunctionFromexe()
}
<cpp>
This will be in .exe
CFormView::Void CallFunctionFromexe()
{
//my function
}
So i one who can understand all this say me how i do all this ?
This is some ascii work also
Dll has
Contain Resource------>One Dialog with Button1
| |
| |
| |
| Dialog::OnButton1()
| {
| callfunctionfromexe()
| }
|
|
|
exe has
Importing resouce-------->Function ::Void Callfunctionfromexe()
from .dll
SO when button1 will clicked so function will call from .exe using resouce .dll
Suggestion required !!!!!!!!
thanx
naresh
|
|
|
|
|
Hi everybody,
Does anybody know, how I can derive from an ATL object?
I have an ATL 3.0 project and I want to have a base class (suppose CMyBase) with some members, and an interface (suppose IMyBase) with some exposed methods and properties. how do I create a new ATL object that is derived from that class? I mean that the new ATL object inherits members from CMyBase and methods and properties from IMyBase.
Regards,
Roozbeh.
|
|
|
|
|
First create the IBaseClass with pure virtual functions of your methods that you want to be derived.
Create another class CBaseClass and inherite it from IBaseClass and implement the methods and functions.
Now create a new simple ATL object, and in the list of inheritances, also include this CBaseClass.
Now you need to add and implement the interface methods that is exposed to the world.
If you are thinking of inheriting one COM object from another, then its not possible.
Hope i got your question right.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hi;)
I'm still a beginner in vc++,me and my friends are devolopeing a network app.(instance messanger),and I need your help at the following topics:
1-making an edit box transparent.
2-creating a menu at a dialoge based app.
3-creating apopup menu.
4-adding a bitmap to a button with it's states.
note:
the project I'm working in is educational one.
finally thank you for your time.
Hatem M Nassar
|
|
|
|
|
I dont know about the first one but you will get the solutions for the others if you try search using the search option here in CP. Or navigate according to the requiremets from the mainpage.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I have a couple global variables that I would like to use in more than one file. What I want to do is delcare the variables in one file and then be able to access them from other files/classes. So for example if I set the value of the variables in file1 I want to be able to retreive those values from the variables in file2. I thought I could do this with "extern", but I can't figure out how. Any help would be appreciated. I tried this
extern TCHAR* var1;
extern TCHAR* var2;
extern TCHAR* cvar1;
extern TCHAR* cvar2; When I compile that though I get an error that the variable has an illegal storage class.
- Aaron
|
|
|
|
|
file1.cpp
TCHAR* cvar1;
...
void somefunc()
{
cvar1 = new char[60];
....
}
-----------------------------------
in common.h
extern TCHAR* cvar1;
....
-----------------------------------
file2.cpp
#include "common.h"
....
void someanotherfunction()
{
printf("%s",cvar1);
}
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hi,
I have a question about the thread issue on the string class. If you do the following, would you need to put a lock around the string code?
Void ThreadFunc()
{
// Only created in each thread, not global.
String strStuff;
While (1)
{
// Do I need to put a lock around this call?
strStuff = “Hello”;
}
}
Void main (void)
{
Thread hThreadStuff[3];
For ( int I = 0; I < 3; ++i)
hThreadStuff [i] = CreathThread(…, ThreadFunc, …);
hThreadStuff.WaitonExit();
}
Thanks in advance,
Ken
|
|
|
|
|
Since strStuff is declared inside the thread routine, each thread would have their own copy. Thus, no locking is required. However, if strStuff was declared outside the routine, then you would need to place a lock around the assignment or any time you where fetching the value of the string.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
strStuff is a local variable so local to the thread too, no need to put any locking,
Here is the simple formula to remember.
in Multithreading:
Local Variable : No Syncronization
Gloabl Variable : Syncronization needed.
Simple but effective way to solve multithreading problems.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Can some give me a tutorial, or walk me through how to use the Microsoft Comunications Control to open serial ports and send information through them?
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
I foud this useful explanation using MFC and MSComm32 ActiveX control 2 years ago and give you original text:
"Creating the project
Make a simple Dialog workspace in MSVC via the MFC App wizard. The options don't really matter, but make sure you check the 'ActiveX Controls' option in when the Wizard prompts you in step 2.
Adding CMSComm to your project
Open your resource editor so you can change the main dialog. Look on the toolbar, and verify that you don't already have the MSComm control there (someone else may have modified the default workspace). It looks like a little phone.
Add the control to your project. Click the Project >> Add To Project >> Components and Controls command from the menu. This command will take a while as MSVC scans the registry for registered controls. Select 'Registered ActiveX Controls' and click insert. Find the object 'Microsoft Communications Control, version 6.0.' (or another version), select it, then click insert, then Ok. At this point MSVC will prompt you for which parts of the ActiveX control you want to add. There should only be one listed, CMSComm, keep it checked. MSVC will generate a wrapper class for the object so you can use it. You can change the file names and class name if you want, but for this purpose, I'll assume you left them as is.
Close the add components dialog.
Now, look at your dialog toolbar, in it, you should see a new icon for the CMSComm object. Select it, and draw one of these onto your main form. An icon will appear, but don't worry, the control itself is invisible at run time.
Initializing the CMSComm control
All this can be done at run time, but for now, let's just set the properties at design time. Right click on the icon for the comm control in your dialog resource and pull up the properties dialog. Under the Control, Buffers, and Hardware tabs, set the properties you desire, such as buad rate, parity, port number, etc.
Add a member for the control
To use the control, you need to create a class member. Open the Class Wizard, and from the Member Variables tab, select the comm control (by default it will be called IDC_MSCOMM1) then click the 'Add Variable...' button. Create a name, I used m_comm. Double check that the variable is a control variable, and that it's of the right class (CMSComm). You can now use this member variable to communitcate with your com port.
Using the CMSComm control
Here's a quick example of how to use the control. It's important to wait until your OnInitDialog() call (or anytime after) before trying to use it because not everything will be created/initialized before this.
Code simple:
CMSComm m_comm; // MFC generated member in the .h file
#include "atlbase.h" // CComVariant support
#define COM_MS_TIMEOUT 5000 // COM1 timeout in milliseconds
// Generate an output.
CString sOut;
// Build your output...
sOut = _T("Hello world");
// Generate a variant for the output.
CComVariant vOut(sOut);
// Send the command.
m_comm.SetOutput(vOut);
// Wait for a reply.
// This is NOT a processor efficient way of doing it,
// but it gets the idea across.
DWORD dwNow, dwTimeOut, dwStart;
dwStart = GetTickCount();
dwTimeOut = COM_MS_TIMEOUT;
CString sIn, sInBuffer;
CComVariant vIn;
for (;;)
{
dwNow = GetTickCount();
if (((dwNow - dwStart) > dwTimeOut) // Timeout elapsed
|| (dwNow < dwStart)) // Happens if tick count wraps past 2^32
break;
vIn.Clear();
vIn = m_comm.GetInput();
sIn = vIn.bstrVal;
sInBuffer += sIn;
// Check a for terminating \r character.
// If we find one, break the loop, otherwise,
// more data is coming.
// The hardware you'll be interfacing with may have a
// a different terminator sequence.
if (sIn.Right(1) == _T("\r"))
break;
}
This is the easy way of doing it. If you're not using a dialog at all, it will be trickier creating the object, since it won't be done automatically by your dialog's ActveX handlers."
For more information see MSComm32 help if you mean additional details and change somethings.
'Also http://www.yes-tele.com/mscomm.html'
Regards,
|
|
|
|
|
I'm trying to get my program to acess a database(.mdb) and change the part of the field it's in.
(ie getting the field2 info for Car4). I have tried many things and I just can't seem to figure it out. Thank you for your help.
____________
|Field1|Field2|
|Car1 |Ratio1|
|Car2 |Ratio2|
|Car3 |Ratio3|
|Car4 |Ratio4|
|Car5 |Ratio5|
|
|
|
|
|
Should be something like:
Update Field2 where Field1 = Car4
Not sure about the syntax for that database.
Not sure if I was any help.
Good Luck,
Jerry
|
|
|
|
|
Have you tried using ClassWizard to derive a class from CRecordset ? It will ask you for a data source name (which is tied to your Access file). That class will then contain a member variable for each column (i.e., field) in the database. For querying the rows, the default SQL statement will effectively be SELECT * FROM . To update a row, you'll set the m_strFilter member, then call the Requery() method. At that point, the record pointer is on the row you want to change. Call Edit() , assign each of the record set's member variables their new value, and call Update() .
This is not an exact recipe, but it will get you going. Using the keywords I've shown here, search here at CP, or MSDN, for a bunch of examples.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I don't want to change the fields just get the info thats in them. So in my code if I put something like
SELECT* FROM gear
m_strFilter.Requery(variable);
right or that wouldn't work? Thank you for your help.
|
|
|
|
|
MrNiceBerG wrote:
SELECT* FROM gear
Put this as the return value from GetDefaultSQL() .
MrNiceBerG wrote:
m_strFilter.Requery(variable);
right or that wouldn't work?
No, because Requery() accepts no parameters.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hello:
When using Date Time Picker, it defaults to Dec 31, 1969. If I select a date before that, once I do a UpdateData(TRUE), I get an error Debug Assert Error - timecore.cpp line 40. ----> ASSERT(m_time != -1);
How can I limit the dates that can be selected? How can I make it default to today's date?
Thank you
CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec,
int nDST)
{
struct tm atm;
atm.tm_sec = nSec;
atm.tm_min = nMin;
atm.tm_hour = nHour;
ASSERT(nDay >= 1 && nDay <= 31);
atm.tm_mday = nDay;
ASSERT(nMonth >= 1 && nMonth <= 12);
atm.tm_mon = nMonth - 1; // tm_mon is 0 based
ASSERT(nYear >= 1900);
atm.tm_year = nYear - 1900; // tm_year is 1900 based
atm.tm_isdst = nDST;
m_time = mktime(&atm);
----> ASSERT(m_time != -1); // indicates an illegal input time
}
|
|
|
|
|
I think CDateTimeCtrl::SetRange() is what you are after.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi
It is somebody who had some problem before with this type of exception ?
EXCEPTION_IN_PAGE_ERROR
Thanks,
Florian Szoke
|
|
|
|
|