|
DavidCrow wrote: That would be the route I'd choose.
Sometimes the simplest solution eludes even the best of us. No reason to re-invent the wheel when office is capable of working with the simpler formats. The PDF files now on the other hand well they would be just a pain in the but, unless your running subversion.
|
|
|
|
|
Hello,
I have an unmanaged C++ dll that I would like to load in a managed C++ application. I can call methods in the dll from an *unmanaged* program with no issues.
I set up the import using:
[DllImportAttribute("lib.dll")] int function();
The project is correctly set to find the libary files.
When I run the compiled program, it throws an execption at the line:
function();
The exception is:
An unhandled exception of type 'System.EntryPointNotFoundException' occurred in testManaged.exe<br />
<br />
Additional information: Unable to find an entry point named function in DLL lib.dll.
This error indicates that it cannot find the function in my libarary, but I know the function is there and accessible because I can access it from unmanged code. Is there something wrong with my import statement? Anything else?
Thanks,
--Jordan
-- modified at 23:40 Thursday 19th January, 2006
|
|
|
|
|
Try adding a ExactSpelling=true . I think the syntax would be like this:
<br />
[DllImportAttribute("lib.dll", ExactSpelling=true)] int function();<br />
But I'm not a dotNET guru...
Steve
|
|
|
|
|
The ExactSpelling attribute did not fix it (I get the same exception), but thank you for the suggestion.
--Jordan
|
|
|
|
|
Can you post the declaration of the unmanaged function (so I can check the calling convention) - The C++ code.
Steve
-- modified at 0:06 Friday 20th January, 2006
FIXED errors
|
|
|
|
|
Stephen,
The function was declared as:
LIB_API int function(void);
where I have
#define LIB_API __declspec(dllexport)
Changing it to:
extern "C" LIB_API int function(void);
seems to have fixed the problem -- I'd be happy to hear an explanation for that if you have one.
Thanks,
--Jordan
-- modified at 0:14 Friday 20th January, 2006
|
|
|
|
|
|
I need to develop an exe which runs as an NT Service. My requirement is that I need to spy a folder and encrypt all the new files that come into that folder.
Only the adminstrators should have permissions to stop the service.
I figured out how to spy the folders from code in this site.
Also got the code to run as an NT Service, but could not write an event which on start of NT Service invokes the part to watch directories. And on stop of service unwatches the directory.
Please help me out. Also suggest me how to achieve this if the earlier project in this site could be used.
Ref: http://www.codeproject.com/system/cntservice.asp
Udaybhaskar
|
|
|
|
|
udaybhaskar_nori wrote: lease help me out. Also suggest me how to achieve this if the earlier project in this site could be used.Ref: http://www.codeproject.com/system/cntservice.asp
Mr. Naughter Provided a Demo application with the Service.. where he derived a class from CNTService and created a beeping program.. you have to see code of void CMyService::ServiceMain(DWORD /*dwArgc*/, LPTSTR* /*lpszArgv*/)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks for your prompt reply.
Yeah I have seen that program. In place of the beep I tried to keep an AfxMessageBox. The service stops responding. Can I write MFC code in that place.
Do I need to call any other method there, before calling MFC code?
Thanks in advance.
Udaybhaskar
|
|
|
|
|
|
|
kakan wrote: A service doesn't have a window so you should avoid all GUI operations, including MessageBox in a service
Little Contradiction Sir, I had placed Dialog Box in the service and it works fine for me.. moreever I have used winsock in that project too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV
|
|
|
|
|
udaybhaskar_nori wrote: Yeah I have seen that program. In place of the beep I tried to keep an AfxMessageBox.
You service stop responding because message box have a modal loop!, so you have to respond to MessageBox before interecting with service, Now as Mr. PJ naughter service is not desktop interective by default, you have to make it desktop interective to respond to messagebox and make it messagepump running.
for making Service desktop interective :-
Open Computer Management--> choose Service and Application Tree Item --> choose service tree sub item---> find you service is listed service -> right click on service and choose properties -> now choose LOG ON tab and Check Allow service to interect with desktop check box
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV
|
|
|
|
|
Yes it worked for me that way. But I am getting a lot of debug assetions in debug mode. I am creating a reference to a class and calling a method of that class. What could be the reason? Are there any exceptions in using dialog code.
Udaybhaskar
|
|
|
|
|
udaybhaskar_nori wrote: What could be the reason? Are there any exceptions in using dialog code.
I have read some where you cannot run the Service in debug mode
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
I have used the MFC Wizard to create a function such as this one, and it produced the following,
when I run the ActiveX it crashes the program, I had posted a similar problem before using variants and it fixed when Steve mentioned that a [out] is required in from of a pointer so I attempted it here and I got an error
Before Steve's fix
[id(10), helpstring("method testing")] void testing(BSTR * test );
After Steve's Fix
[id(10), helpstring("method testing")] void testing([out]BSTR * test );
This didnt do it for this case, I havent done anything else to the function, all I'm doing is assigning a fixed BSTR to the pointer, but even with this comment I get an error telling me that there is a type mismatch
Any help would be greatly appreciated
|
|
|
|
|
I want to build my project whose execute file (.exe) have an icon I chose. How could i do it ?
|
|
|
|
|
The first icon (lowest numbered identifier) in the resource section of your executable will be used as the application icon. Just add an icon to your project and give it the ID 1.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Assuming you are using MFC, the ID of your application's icon will be IDR_MAINFRAME (i think.. check that). Now, import the icon you want and rename the ID of it to IDR_MAINFRAME (delete the previous icon before this or rename the ID of that to something else).
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
No, im using raw api. That's the problem.
|
|
|
|
|
I assume that the program was created with the default MFC icon.
So just replace the icon file with one of your choice, and rebuild the resources. Simplest is to just rebuild the whole project. Then the new icon is used instead of the old one.
Shraddhan
|
|
|
|
|
What I want:
<br />
#define PACK_STRUCT_BEGIN #pragma pack(1)<br />
So I don't have to use #pragma explicitly.
Too many #pragma makes my code look ugly.
But compiler tells me it is a big mistake,and I don't know the reason.
Is it because #pragma is a compiling control word?
I expect an answer.
Appreciate.
Never understand
radical version!
|
|
|
|
|
You can't put preprocessor commands in a macro. Otherwise, the preprocessor would have to make multiple passes through the code, which it doesn't do. You'll have to use #pragma directly.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a max file name length for all files (to make sure a char buffer is always large enough)? I was assuming it was MAX_PATH but is that just for the path part and the fully qualified name can be longer?
- thanks.
|
|
|
|