|
Comp_Users wrote: Could you please tell me as to what is causing this to happen?
The linker is telling you exactly what the problem is.
You need to put the function declarations in a .h file like:
#if !defined(ABC123)
#define ABC123
#pragma once
int TrimMyString();
int PaintMyHouse();
int SellMyStock();
#endif You need to put the function definitions in a .cpp file. Make sure both files are added to the project. Then in any file that will be using those functions, simply #include the .h file near the top.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Others have beaten you over the head with it, so I'll join in. You DON'T include cpp files - you include headers.
Try:
extern CString TrimMyString (CString s);
#include "stdafx.h"
#include "TrimMyString.h"
CString TrimMyString (CString s)
{
do stuff with the string...
return s;
}
#include "stdafx.h"
#include <some.h>
#include "Other.h"
#include "TrimMyString.h"
BOOL SomeFunction ()
{
s = " Hello ";
s = TrimMyString (s);
return TRUE;
}
</some.h>
I hope that made a little sense,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I have done exactly the same.
But inspite of this, I keep getting the same link error.
I am using VC++ project.
|
|
|
|
|
Problem solved.
It was the exact problem that you guys had rigthly pointed out.
Thanks a lot. ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hi there.
I have a DLL that was being created in C#.net with an exported class/functions.
Now, I want to call exported class/functions mentioned above from my code C++ code.
Just an add-on, Can I access all the c# exported classes in C++ console application? If Yes, the please provide pointers/sample code on this.
Thanks and Regards
PanB
modified on Tuesday, February 10, 2009 8:26 AM
|
|
|
|
|
PankajB wrote: Can I access all the c# exported classes in C++ console application?
No. However you can use a .NET class library assembly from a Managed or Mixed Mode C++/CLI project. CodeProject has an entire forum on the subject called Managed C++/CLI
|
|
|
|
|
|
UpdateAllViews() will update all views.
How to update single view?
|
|
|
|
|
Me think you will need to have a pointer of some sort to that view in order to update it.
or you could iterate (see CDocument::GetFirstViewPosition and CDocument::GetNextView and CView::OnUpdate ) the views in your application and decide if one view needs updating.
The way you decide if a view needs to be updating is up to you and not framework dependent (AFAIK).
This signature was proudly tested on animals.
|
|
|
|
|
KASR1 wrote: UpdateAllViews() will update all views.
How to update single view?
This function does not do any updating. It merely calls the OnUpdate() member function for each of the document’s views except the sending view, passing pHint and lHint . You need to specify a specific lHint value so that the single view will know it needs to update itself.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello,
my Name is Harry Diel and I’m a Software-Engineer (Development) here in Germany.
A couple of years ago (2000-2005) I developed for a Medical-Assosiation under Windows XP and Server 2003 with MFC und Visual C 6.0 a LAN-Manager System with some RPC-programs, which where running as services on several clients, in a large System-LAN environment with more than 1500 installed workstations (NT/XP), Printern and over 200 Servers with Windows 2003 / NT. everything was OK, until now the first Windows Vista will be used.
The Time has come to upgrade to Windows Vista !!!!
Now I updated my C-Programs to Visual C++ 9.0 and VS 2008. The functionalities of the program were still the same, nothing changed. But now I get from the StartServiceCtrlDispatcher Function always the Error-Code “1063” =
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. (Only when the service starts on Windows Vista).
I need help, what can I do. I tried everything, but nothing works and helps realy.
Enclosed you will find a piece of my Program-Code of the C++ program, when the service should start working. But it stops!!!!
Maybe you can send me an example for Windows Vista how it would work.
I am waiting for an answer. Thank you.
regards
harry Diel,
47475 Kamp-Lintfort, Germany
E-Mail: harry.diel@t-online.de
1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 int Win_RemComServiceMain (void)
3 { ///////////////////////////////////////////////////////////////////////////////
4 sprintf (szOpenFName,"%s","C:\\Temp\\RemComLogDatei.log");
5 hOpenF = CreateFile (szOpenFName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,
6 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
7
8 if (hOpenF == (HANDLE)ERROR)
9 { hOpenF = NULL;
10 }
11 ///////////////////////////////////////////////////////////////////////////////
12 _GetDateAndTime();
13 sprintf(sWrkBuff,"%.6s | %s\tWin_RemComServiceMain\t: LogFile gestartet.%s",ActDatum, sCurrTime, EOR);
14 WriteErrorText_2 (sWrkBuff);
15 ///////////////////////////////////////////////////////////////////////////////
16 // Register the service control handler
17 g_hstatus = RegisterServiceCtrlHandler(REMC_SERVICENAME, ServiceCtrl);
18 if (g_hstatus == 0)
19 return FALSE;
20
21 // Setzen einiger Service-Standard Status-Values
22 g_ServiceMode = TRUE;
23 SetProcessShutdownParameters(0x100, 0);
24
25 // Erstelle einen Service Tabellen-Eintrag
26 SERVICE_TABLE_ENTRY dispatchTable[] =
27 { {REMC_SERVICENAME, (LPSERVICE_MAIN_FUNCTION) RemComDoService},
28 {NULL, NULL}
29 };
30 ///////////////////////////////////////////////////////////////////////////////
31 _GetDateAndTime();
32 sprintf(sWrkBuff,"%.6s | %s\tStartServiceCtrlDispatcher\t%s%s",ActDatum, sCurrTime, REMC_SERVICENAME, EOR);
33 WriteErrorText_2 (sWrkBuff);
34
35 // Aufrufen des Service-Control-Dispatcher mit unserem Tabellen-Eintrag
36 bRetc = StartServiceCtrlDispatcher(dispatchTable);
37 if (bRetc == TRUE)
38 { return TRUE;
39 }
40 SvcError = GetLastError();
41 if (SvcError == ERROR_SERVICE_ALREADY_RUNNING)
42 return TRUE;
43 else
44 { _GetDateAndTime();
45 sprintf(sWrkBuff,"%.6s | %s\tStartServiceCtrlDispatcher\tFehler = %d%s",ActDatum, sCurrTime, SvcError, EOR);
46 WriteErrorText_2 (sWrkBuff);
47 return FALSE;
48 }
49 }
50
51 ///////////////////////////////////////////////////////////////////////////////////
52 // RemComService Main-Routines
53 ///////////////////////////////////////////////////////////////////////////////////
54 BOOL WINAPI RemComDoService (DWORD argc, char **argv)
55 {
56 // Setzen einiger Service-Standard Status-Values
57 g_srvstatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS;
58 g_srvstatus.dwServiceSpecificExitCode = 0;
59 // Give this status to the SCM
60
61 if (!ReportStatus (SERVICE_START_PENDING, NO_ERROR, 15000))
62 { ReportStatus (SERVICE_STOPPED, g_error, 0);
63 return FALSE;
64 }
65
66 hRemCThread = CreateThread (&SecAttributes, NULL,
67 (LPTHREAD_START_ROUTINE) RemComServiceThread,
68 NULL,
69 NULL,
70 &dwThreadId);
71 ///////////////////////////////////////////////////////////////////////////////
72 _GetDateAndTime();
73 sprintf(sWrkBuff,"%.6s | %s\tRemComDoService\tCreateThread OK.%s",ActDatum, sCurrTime, EOR);
74 WriteErrorText_2 (sWrkBuff);
75 return TRUE;
76 }
77
78 ///////////////////////////////////////////////////////////////////////////////////
79 // Service Start-Routine - Thread that calls WinVNCAppMain
80 ///////////////////////////////////////////////////////////////////////////////////
81 BOOL RemComServiceThread (void *arg)
82 {
83 g_servicethread = GetCurrentThreadId();
84
85 bRetc = ReportStatus (SERVICE_RUNNING, NO_ERROR, 0);
86 if (bRetc != TRUE)
87 return FALSE;
88
89 ///////////////////////////////////////////////////////////////////////////////
90 _GetDateAndTime();
91 sprintf(sWrkBuff,"%.6s | %s\tRemComServiceThread\tgestartet: Service_Running -> Call DoModal()%s",ActDatum, sCurrTime, EOR);
92 WriteErrorText_2 (sWrkBuff);
93
94 // The Service should start the Dialog !
95 AfxEnableControlContainer();
96 pRemCService->DoModal();
97
98 // Wir laufen nicht mehr ....
99 g_servicethread = NULL;
100
101 ReportStatus (SERVICE_STOPPED, g_error, 0);
102 return TRUE;
103 }
104
105 ///////////////////////////////////////////////////////////////////////////////
106 ///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
what privileges do you run the application with....
You should be an Admin...Vista has some issues that are to be dealt with regarding the admin privileges and running applications under it
Did you try running the service when you are logged in as a local admin?
****************Also check the firewall..... on the Vista Machine
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Tuesday, February 10, 2009 6:59 AM
|
|
|
|
|
Hello,
thank you for your E-Mail.
But I checked everything. My account has all administrator-rights.
When the service starts, it starts under the system-account and this is always an admin.
I checked the firewall and the program is already configured, to go thru.
I think, there's some mistake in the Vista System-Control-Manager.
It works correctly under XP and NT and 2003.
Thank you.
regards
Harry Diel
|
|
|
|
|
Hello!
Did you manage to find a workaround for this issue? I have the same issue and I also found a plenty of other threads with the same issue. Too bad all of them do not have answer...
|
|
|
|
|
Hi,
I am useing CTreeCtrl class to build tree. I want to add CString as a additional parameter(LPARAM) to leaf node. How can I add/retrive LPARAM?
For Insertion I am Using:- tree.InsertItem("Employees", 0, 0, TVI_ROOT);
And For retrival I Am using:- HTREEITEM hCurSel = tree.GetNextItem(TVI_ROOT, TVGN_CARET);
Please suggest If I need to use different method for it or modify above method for add/Retrive LPARAM.
Thanks:-
Mike
|
|
|
|
|
What about SetItemData [^] and GetItemData [^] methods?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I am not sure about SetItemData() and GetItemData() will solve my purpose. I want to send some CString value with each leaf node. e.g If you insert node 'Employee1' in the tree I will add 'EmployeeId1' as a LPARAM. So that next time when i retrive the node data I need to get LPARAM(Id associated with leaf node) somehow. Please suggest how this can achive?
Thanks:-
Mike
|
|
|
|
|
mikert_2008 wrote: I am not sure about SetItemData() and GetItemData() will solve my purpose.
I'm pretty confident about (I trust in your skills ).
With SetItemData you may store a pointer to your string (the string should not vanish in the meantime...). With GetItemData you may get back such pointer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As CPallini suggested, you should use SetItemData and GetItemData, these can store and retrieve a 32 (or 64?) bit value, so you can't use a string, BUT you can either use a pointer to a string OR maybe an index into an array of strings, of course you will have to maintain these somehow, so if you remove an item you also manually need to remove the string or when you add the item you will have to add the string.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
I've created a animated cursor which is 32x32 RGB/A. I tried to load it in my project (VS6) but it's not loading. Here are the steps I've done plus some code:
1. I've add my cursor (named 'OrangeWait.ani') in res folder,
2. defined new ID for it in 'resource.h'
#define IDR_WAIT_CURSOR 124<br />
3. added line in *.rc file
IDR_WAIT_CURSOR ANICURSOR "res\\OrangeWait.ani"<br />
4. and added some code for testing
HCURSOR hCWait = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_WAIT_CURSOR));
if(!hCWait)
{
AfxMessageBox("Can't load Wait cursor!");
return;
}
HCURSOR hCStandard = ::LoadCursor(NULL,IDC_ARROW);
if(!hCStandard) AfxMessageBox("Can't load Standard cursor!");
SetCursor(hCWait);
Sleep(3000);
SetCursor(hCStandard);
When I start the app I get message "Can't load Wait cursor!".
Any idea?
Thanks...
|
|
|
|
|
Just worked out.
It seems I forget to rebuild.
Funny.
|
|
|
|
|
It's odd!!!
I've changed the animated cursor for another one and replace it. Rebuild and back to "Can't load Wait cursor!" message.
I've double checked everything but no, still wont work. Now it seams as rebuilding isn't the issue here.
I even try to go back but to my original ani cursor still can't load it?! Then I tried to import animated cursors in the following way:
- On Insert Resources dialog box clicked Import
- Imported my animated cursors
- Specified 'ANICURSORS' as type, and clicked 'OK'
, but this too didn't give desired result. The same msg displayed.
Did anyone successfully added animated cursor (32x32 RGB/A) and got it to work in VS6? If so how?
|
|
|
|
|
I found the new way to succeed, only this lines of code do the job
HCURSOR hCursor = LoadCursorFromFile("res\\AnimatedCursor.ani");
if(hCursor)
SetCursor(hCursor);
Off course 'AnimatedCursor.ani' is the name of my source file.
But another problem appeared when running under release mode, cursor is not loading. Why?
It's a little sadly when talking to my self, isn't it?
|
|
|
|
|
Well I can get really stupid some times can I?
The file needs to be distributed along with application or it can not find and load it.
Obviously if I want it to work I need to go back and include my ani cursor in my resource.
But I cant get it to show (see previous posts). Does anybody know the solution to my problem?
|
|
|
|
|
hi guys,
i am creating a VC++ program that connect to mysql database on remote server.i have tried few steps but it didnt work.i need advice on which database i should use and it must be in a remore location.
i create a mysql database on speedhosting.co.cc but its a database for php. Is it possible for a C++ program connect to it and get data from there ??
|
|
|
|
|