|
i don't think that this is the problem. The app fails also on some of the clients. I've mentioned that it fails on the server to show that it is not a LAN problem.
Anyways, my XP station connects to that server and runs just fine but even if i set this station to be the server, the win98se one won't work
|
|
|
|
|
I really do not know what caused this problem but installing the latest MDAC from microsoft solved it It's strange but i remember having a problem that crealy pointed to a data access problem. I fixed it then by installing MDAC 2.8 but it didn't work this time. What fixed it was MDAC 2.8 sp1...
|
|
|
|
|
Hey folks, last time I'm posting about this... thing is, no one reads the posts that appear to have answers, even if they are unsatisfactory
My requirements:
1) No MFC
2) No .NET calls (straight-up c++)
3) Read an ASCII file on disk using calls to ReadFile()
4) Store that data read from the file into the c++ string type.
5) Use C++ STL (because I'm already using string manipulation functions from the STL)
6) Call methods that require the use of LPTCSTRs from the WIN32 API (using my c++ STL strings, converting them somehow if necessary)
7) Write back to the ASCII file mentioned in #3 using LPTSTRs using WriteFile().
8) Rinse & repeat.
My questions for you:
1) I'm a c++ / Win32API / STL newbie, so please provide a clear answer any idiot could understand (me :p), with an example if possible.
2) I'm not sure if _UNICODE is enabled, or how that effects my ability to meet my requirements.
3) I've seen the following code, and it seems to me that if I can just fool C++ into accepting that in the string contanier, it will actually store TCHARs, this sounds good. But I really have no idea how to use it:
typedef std::basic_string< TCHAR > tstring;
#ifdef _UNICODE
#define tstring wstring
#else
#define tstring string
#endif
If you need clairifcations, please feel free to post here, or email me at membos AT yahoo DOT com.
|
|
|
|
|
wstring and string classes have a member function called c_str() which return const pointer to c style string.
for example :
string str1 = "some string";
wstring str2 = "some wide string";
const char* c_str1 = str1.c_str();
const wchar_t* c_str2 = str2.c_str();
now LPCTSTR is define as
#ifdef UNICODE
typedef const wchar_t* LPCTSTR;
#else
typedef const char* LPCTSTR;
#endif
so all you need to do is use c++ string or wstring and when you have to call Win32 API function using c_str() to get a pointer to c_style string.
Hope this helps,
-Saurabh
|
|
|
|
|
Hello,
here my problem with socket:
I've got a simple program with a main that calls a dll dynamically.
Example:
int main(int argc, char *argv[])
{
HINSTANCE lib = LoadLibraryA("C:\\mylib.dll");
if (lib == NULL)
printf("LoadLibraryA failed\n");
}
As my dll has a "DllMain" function, it automatically enters in it and it executes code I want to.
My problem is I want to init socket there and whatever I do the "socket" function failed.
My code compile so I've got the good includes and i've attach the Ws2_32.lib in my dll.
Example:
<code>SOCKET m_socket;
WSADATA wsaData;
int res;
res = WSAStartup(MAKEWORD(2,2), &wsaData);
if (res != NO_ERROR)
{
printf("Error : WSAStartup() [%ld]\n", WSAGetLastError());
return 1;
}
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_socket == INVALID_SOCKET)
{
printf("Error : socket() [%ld]\n", WSAGetLastError());
WSACleanup();
return 1;
}
...</code>
Socket function always failed with this error code: 10091 that is in MSDN: WSASYSNOTREADY
In MSDN it is said that this error is returned by WSAStartup. However for me it is the socket function.
If I translate my socket code directly in my main program, it works pretty well. As a consequence, are there some trouble to deal with socket in a dll called dynamically?
Thanks for your help.
-- modified at 14:32 Monday 17th April, 2006
|
|
|
|
|
Well, the first problem is you shouldn't be doing any of that in DllMain() . DllMain() is for simple initialization tasks. Calling into other DLLs from DllMain() will at best fail, and at worst deadlock the process.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Ok, I've done it works. Effectively, don't do that in your DllMain function but do it via an invoked function.
Thanks for your tips Mike.
|
|
|
|
|
Hello All of you,
Using VC++6(MFC)now i am able to draw the line, circle, ellipse, rectagle. Suppose i want to give them the dimension and modify the corresponding dimension then what should i do.
Is there any source code that can guide How the dimensions given to the geometric entities and modify it.
|
|
|
|
|
Somewhat of a trivial question but I never did grasp the concept. I know that using the new operator we are able to create arrays of a runtime defined size. But this is when you know exactly what size you need the array. eg.
char *foo = "Hello world";
char *bar = new char [strlen(foo) + 1]; But, lets say that code is within a loop, and I want to keep increasing the size of the array without loss of data. How is this done?
In a pratical example, I am working on some code which will open an excel like workbook. Upon reading the file the worksheets are found 1 by 1 and not all at once. Therefore I need to create an array of worksheets and enlarge it each time a new worksheet is found.
|
|
|
|
|
If using MFC, using the CArray<> template. If using STL, using the vector<> template.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I know vectors are ideal for this, but I would rather not use them if possible in this instance. I was simply wondering how a vector like array would be coded.
|
|
|
|
|
You'll need to create a new array that is one size larger than the current one, copy the contents of the current one to the new one, delete the current one. Make sense?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
It makes sense, though it isn't very efficient. We are basically copying the data 2 times, first to a buffer, then back to the resized array. I was hoping for a better way of resizing an array, but this will suffice.
|
|
|
|
|
waldermort wrote: I was hoping for a better way of resizing an array, but this will suffice.
Basically, that's how the existing containers operate, with one important distinction: when they grow, they do it exponentially - not by one. Thus they reduce the number of copying at the expense of memory space.
Of course, once we have the move semantics in C++ (around 2010, I hope ) this will be a non-issue.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote: Of course, once we have the move semantics in C++ (around 2010, I hope ) this will be a non-issue.
So you don't think we are going to be pushed towards the .NET way of things before then?
|
|
|
|
|
waldermort wrote: So you don't think we are going to be pushed towards the .NET way of things before then?
.NET is a platform, C++ is a programming language. I know quite a few people who make very nice salaries programming with languages like COBOL and Fortran.
But that's a bit OT, anyway.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
If you are using objects with simple types that need no destruction, you could use alloc() / realloc() . (I've long felt C++ should have a renew keyword, but it never happened.)
(EDIT: you could wrap these in a simple class to ensure proper destruction.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
I disagree--they overthought it; however I wrote a template class that contains a malloc/realloc that serves the same purpose.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I need to enumerate network resources from my service and for this i plan to use impersonation.
This is what i did.
LogonUser(username)
ImpersonateLoggedOnUser()
// do networking stuff
RevertToSelf()
when i perform these operations with username = Administrator, the networking code works fine but with
username = xxxx (which belong to the Administrators group), the networking code fails (GetLatError = 2).
What am i doing wrong here ?
As i see the username(xxxx) does not have a few access rights or privileges which the Administrator has to
enumerate network resources. any idea what are those rights or privileges ?
I tried with granting SeNetworkLogonRight to xxxx and it did not work.
any inputs will be helpful.
|
|
|
|
|
Hi Folks,
I am facing a little problem executing my program..
I am using an MFC APP Wizard Application, which was running fine untill I added a function[ Find() ] in my View class which uses a global function [ int getAngle() ].
I defined my global Function and Variable in a seprate header and use #include "Global.h" on top of my View Class (.h).
If i dont define this global function [ int getAngle() ] in "Global.h" and build my program the compiler complains about [ int getAngle() ] not declared and used in function [ Find() ].
But as soon i define the function [ int getAngle() ] in "Global.h" and build my program i get linker errors saying
"SimulationView.obj : error LNK2005: "int __cdecl GetMap(int,int)" (?GetMap@@YAHHH@Z) already defined in Simulation.obj
...
SimulationView.obj : error LNK2001: unresolved external symbol "int __cdecl getAngle(class MapNode,class MapNode)" (?getAngle@@YAHVMapNode@@0@Z)
Debug/Simulation.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe. "
Can anyone of u guys figure out whts the problem ???
Regards,
JinBaba
|
|
|
|
|
It looks like you are including Global.h in more than one spot. You need to add something like the following to it:
#ifndef _GLOBAL_H
#define _GLOBAL_H
int getAngle();
#endif
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi David,
The thing is i am including "Global.h" in more than one spot.. but i have already followed the convention of
#ifndef _GLOBAL_H
#define _GLOBAL_H
#endif
but I still get the same problem.
Your Response needed..
Regards,
JinBaba
|
|
|
|
|
You might also employ the #pragma once directive.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi David,
The thing is i am including "Global.h" in more than one spot.. but i have already followed the convention of
#ifndef _GLOBAL_H
#define _GLOBAL_H
#endif
but I still get the same problem.
Your Response needed..
Regards,
|
|
|
|