|
Agree but I need to deliver a single exe.
|
|
|
|
|
[DllImport("Kernel32.dll")]
extern int AllocConsole();
[DllImport("Kernel32.dll")]
extern int FreeConsole();
[DllImport("Kernel32.dll")]
extern int AttachConsole(UInt32 dwProcessId);
...
AllocConsole();
Console::WriteLine("Write to the console!");
...
FreeConsole();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Great. Good to learn new things every day.
Best wishes,
Navaneeth
|
|
|
|
|
Hi,
My VC++ application(managed code) uses unmanaged code library(.lib) and am using VS2005.
During deployment, I also need to send few more dlls along with the exe. I just want all the modules (external dlls to be deployed and the exe) into a single exe.
I tried using ILMerge, but when i run the merged exe it throws up exception as "bad unmanaged code entrypoint". But if i try the same with pure managed code(without any unmanaged lib included), then the merged exe runs fine.
I also tried Netz. Could not successfully run with this too. Pure managed code runs fine here too.
So, clarification i need is whether the exe generated from a code(which has both managed and unmanaged code) can be merged with dlls? if yes, pls let me know the steps too.
Thanks in advance
-Santosh
|
|
|
|
|
Can't you statically link those libraries rather than providing DLL's?
Best wishes,
Navaneeth
|
|
|
|
|
Those DLL's are microsoft provided. I just want to avoid deploying msvc**.dll files.
Am amateur in application programming. So want to know Can DLL's be statically linked? if so how?
|
|
|
|
|
IL merge can work only with managed assemblies. I guess mixed mode and native DLLs are not supported. IMO, you don't have to deploy msvc runtime files manually. Get the redistributable package from MSDN and install it on target machine before your application is installed. That should install all the necessary dependencies.
Best wishes,
Navaneeth
|
|
|
|
|
Agree with your suggestion but my application will be used by the production line zombies. So, asking them to get the redistributable installed is a huge task for them.
Hence packaging everything into one is the solution i see. pls let me know how to do this.
Thanks
|
|
|
|
|
Hey guys. Maybe thats stupid question, but i am pretty curious why
i cannot inject a thread from application written in managed c++ .NET into for example
notepad.exe.
The code i am trying to inject is not .net - it is win32 code. NET in this example
used only for GUI - simple window with button "Inject", the rest of code is win32 only.
Actually the rest of the code is simply copied from console C application.
I am curious because, for example, i can inject a working thread from win32 application into native application(for example, from my_proggie.exe - which is win32 app, into smss.exe - which is pure native) if i am injecting native functions (for example, not OpenProcess but NtOpenProcess), why i cannot do the same thing here? And by the way, is it possible at all? I know it is possible to inject a dll loading routine even from C# app into C app, but how about a thread?
|
|
|
|
|
csrss wrote: i can inject a working thread from win32 application into native application(for example, from my_proggie.exe - which is win32 app, into smss.exe - which is pure native
I thought Win32 applications are also called as native. What do you meant by pure native? Also what is thread injection and what are you trying to achieve by that?
Best wishes,
Navaneeth
|
|
|
|
|
What am i trying to achive... for example i want some remote process to do something for me and i dont want to do it from my process, or i just need to get into remote process, or i am doing it just for fun. There are many reasons i might need to use it.
Win32 apps are win32 subsystem specific apps and they are not native, well you can call them native but thay are higher level then, for example, csrss (client-server runtime subsystem) app, or smss(session manager subsystem), you cannot run them inside win32 subsystem. for example disk check util. is native too - it runs before win32 subsystem initialization. For example CreateFile is win32 API, while NtCreateFile/ZwCreateFile is native API. And you know that ZwCreateFile you can call from win32 app, native app and kernel mode driver. But if you will try to inject some thread into, for ex. csrss, lets say thread has one function - ExitProcess, it will not work, but if NtTerminateProcess((HANDLE)-1, 0) will be injected - you will have a BSOD, because you forced csrss to shutdown itself.
Thats what i am talking about - just playing with system internals.
So i tried to do some injection stuff from managed c++ .NET and it is not working, and i dont know why. Maybe thats all about this .NET platform, code translating is some kind different. Well, what is funny it cannot even inject into itself - probably i have to do some debugging to get idea why is that so. Or i am missing something with function pointers and addresses? Thats whay i have posted my question here in hope to get some detailed info how these things works in case of managed c++
|
|
|
|
|
Hi All
I am using mysql,::_RecordsetPtr pRecordset and ODBC.I create database through code
<preprecordset=m_pconn->execute(_bstr_t("create database="" clientname"),0,="" adcmdtext);="">
It's work fine but i want to use refresh after creating database.There is any way to refresh mysql database through code.Plz help me
|
|
|
|
|
What do you mean by refresh database? And why are you using ODBC to connect MySQL from Managed code? A better alternative would be the connector provided by MySQL.
Best wishes,
Navaneeth
|
|
|
|
|
>(resources->GetObject(L"Ythree.Image")));
I need some help. The above code gets an image from .resX file.
What is the code if i want to load an image from the app.rc file?
I am finding that using resX, if i am using the same image more than once a new copy of the image is being created on executing the application and the code modified to point to images created when the program is executed.
Thanks for the time.
|
|
|
|
|
i think i have to use the imageList control for this as resX is the .net way of doing things.
|
|
|
|
|
if images are imported/used in resX using imagelist.
how do i store audio clips in the application resources? do i use app.rc for that?
also i would like to embed icons in it also. how and where do i store them?
thanks.
|
|
|
|
|
ok i think i have figured out how resX works.
thanks.
|
|
|
|
|
Yup, I did Google but nothing helped. I get strange linker errors.
Error 1 error LNK2001: unresolved external symbol "extern "C" int __cdecl wsprintfW(wchar_t *,wchar_t const *,...)" (?wsprintfW@@$$J0YAHPA_WPB_WZZ) ComPort.obj Lab1
Error 2 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegQueryValueExW(struct HKEY__ *,wchar_t const *,unsigned long *,unsigned long *,unsigned char *,unsigned long *)" (?RegQueryValueExW@@$$J224YGJPAUHKEY__@@PB_WPAK2PAE2@Z) Lab1.obj Lab1
Error 3 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegQueryInfoKeyW(struct HKEY__ *,wchar_t *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,unsigned long *,struct _FILETIME *)" (?RegQueryInfoKeyW@@$$J248YGJPAUHKEY__@@PA_WPAK22222222PAU_FILETIME@@@Z) Lab1.obj Lab1
Error 4 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegEnumValueW(struct HKEY__ *,unsigned long,wchar_t *,unsigned long *,unsigned long *,unsigned long *,unsigned char *,unsigned long *)" (?RegEnumValueW@@$$J232YGJPAUHKEY__@@KPA_WPAK22PAE2@Z) Lab1.obj Lab1
Error 5 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegOpenKeyExW(struct HKEY__ *,wchar_t const *,unsigned long,unsigned long,struct HKEY__ * *)" (?RegOpenKeyExW@@$$J220YGJPAUHKEY__@@PB_WKKPAPAU1@@Z) Lab1.obj Lab1
Error 6 fatal error LNK1120: 5 unresolved externals Lab1
The linker throws errors only in a Release configuration. In a Debug conf the project compiles successfully.
If I comment out lines where I use the functions above, the code compiles. But certainly is not what I want.
What's interesting, I use other functions from WinAPI and they work. Also wscanf_s compiles with no errors.
Also, wiping .obj files out (and all other which are generated during compilation) does not help
Thanks in advance --
Greetings - Jacek
|
|
|
|
|
Release -> Project properties -> Config -> Linker -> Input -> Additional Dependencies -> remove "NoInhert".
Phew... I had spent 3 hours searching and only after posting on CP I solved the problem. Thank you!
Greetings - Jacek
|
|
|
|
|
Here is my setup.
- c# wrapper calls managed c++ API code
- managed c++ calls unmanaged API code (c++ compiled with the /clr flag, located in the same project) using static funtions
- API tries to instantiate object defined in another dll (native c++)
void Screen::EvaluateScreen(LPCTSTR lpStrScreen, LPCTSTR lpStrSetName, LPCTSTR lpStrPeriods)
{
NativeDocument *screenDoc = NULL;
screenDoc = new NativeDocument;
calling the constructor causes a "Attempted to read write protected memory. ....memory corupt?..." error in the contstructor code.
I'm new to c++ coding as well as this interop stuff. Any ideas? Is there an issue instantiating native code from inside the /clr compiled c++? The code i'm using (EvaluateScreen) is lifted from another native DLL so the code in there should be good (i guess).
|
|
|
|
|
redivider wrote: Is there an issue instantiating native code from inside the /clr compiled c++
No. /clr compiler switch indicates that a mixed mode assembly has to be generated. It can work with both managed and unmanaged types.
Where is NativeDocument located? Is that in the DLL? Is your application multi-threaded?
Best wishes,
Navaneeth
|
|
|
|
|
Not multi-threaded.
NativeDocument is in another dll
C# dll -> /clr dll -> c++ dll (w/ NativeDocument class)
|
|
|
|
|
I couldn't reproduce this error. I have created a native DLL which has a sample NativeDocument class. Exported the functions and used this class from C++/CLI. Created a C# application and referred C++/CLI DLL there and everything worked as expected. If you can provide more information to reproduce, I will try.
Best wishes,
Navaneeth
|
|
|
|
|
im trying to use the tableLayoutPanel in my application but am stuck.
the panel seem to work on a grid system the is (y,x) and not (x,y).
i.e. on a (col, row) system and not a (row, col) system.
is there any way i can change this coordinate system?
please advise.
ikurtz.
|
|
|
|