|
I need to solve a problem for reading and writing COM Port data from MIDI application.
1)The software must be able to handle multiple MIDI In and MIDI Out ports simultaneously sending and receiving MIDI data without choking off performance for the application (this will include audio as well).
I am using a modified version of the old Mabry MIDIIO already, MFC COM server in a shared .dll, written in c++. It is currently be compiled down into an .ocx and requires COM registration. It is working in the Visual Studio 2008 environment
But A total rewrite or different solution is a viable option but of course with the fastest, most inexpensive and easiest to maintain solution.
Here are the questions:
1)What direction would you recommend COM control or .net control, .dll, multi-thread, something else and why? If anybody having idea about MABRY Control, Do you think the Mabry control could be reworked into my new solution or would it be better to just take a totally different direction?
2)What is the recommendation? an unmanaged or managed solution?
Regards Usman
|
|
|
|
|
Hi,
This is my first post on this forum so please bear with me.
I'm trying to send epson fx printer code to the dot-matrix printer using function:
char* cSendBuf = "\0x1bl\0x03"; RawDataToPrinter( L"\\\\AGO\\Oki ML 520 Elite (IBM)", cSendBuf, strlen(cSendBuf) );
And I don`t know where to put the text "sample text"? Just behind the code: the text does not print. Before the code: text will not be set to the column specified in the code.
char* cSendBuf = "\0x1bl\0x03\sample text";
char* cSendBuf = "sample text\0x1bl\0x03";
How it should be assigned to a pointer value to char* cSendBuf?
Thanks.
|
|
|
|
|
Hi,
in my experience printing on an EPSON matrix printer doesn't need anything special, it works like all other printers, which means: create a class that derives from PrintDocument, and all is good. That is, assuming you are using the .NET Framework. If you don't, your code isn't managed C++ and your question is in the wrong forum.
If, for whatever reason, you do need to generate ESC/P commands yourself, the language specs can be found with Google, here[^] is one candidate; I trust there are some working examples included. And if you still have questions about it, you still would be (slightly) better of in another forum, probably "Hardware and Devices" (don't hold your breath).
|
|
|
|
|
Hi, everyone. I got some trouble with c++.
IDE: Visual C++ 2010 express
win32 console application
The purpose of this program is: if I input a string such as: "CS101 C++ PROGRAMMING", the string what i've inputed will appear on the screen.
The following is my codes.
#include "stdafx.h"
#include <string>
using std::string;
using std::getline;
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
class GradeBook
{
private:
string courseName;
public:
GradeBook( string name )
{
setCourseName( name );
}
void setCourseName( string name )
{
courseName = name;
}
string getCourseName()
{
return courseName;
}
void displayMessage()
{
cout << "The courseName: " << getCourseName()<<"!" << endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
for( int i = 0; i < 2; i ++ )
{ string name;
cout << "Input Grade book [" << i + 1 << "]" << endl;
getline( cin, name );
GradeBook myGradeBook( name );
myGradeBook.getCourseName();
}
return 0;
}
In this program, I've defined a class named GradeBook who has four member functions. In the main function, if i used "myGradeBook.getCourseName()" there will be no result on the screen. If I use "myGradeBook.displayMessage()", the result will appear on the screen.
who can tell me why. Thank you.
|
|
|
|
|
why can't i edit the string "#include<iostream>" and "#include<string> "on this page?
|
|
|
|
|
I got the answer
the statment should be cout << myGradeBook.getCourseName();
Then the result will be on the screen!
WOW!
|
|
|
|
|
You could also have used your displayMessage() function, which does the same thing for you. Remember the definition of your getCourseName() function, is just to return the string containing the name, so you still need to pass that to a function that will display it, or, as in this case, pass it directly to cout .
|
|
|
|
|
|
Hello people I have the following the code written in C++, converted from Vb.net to C++ from a program, the following code tells the user via message box if the program is running as an admin, see below
Object ^identity = WindowsIdentity::GetCurrent();
WindowsPrincipal ^principal = gcnew WindowsPrincipal(identity);
bool isElevated = principal->IsInRole(WindowsBuiltInRole::Administrator);
try
{
if (isElevated == true)
{
}
else
{
MessageBox::Show("WARNING: Program not running as administrator!", "Credential Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}
catch (Exception ^ex)
{
MessageBox::Show("This program cannot run as performed because your system does not support admin rights, program now terminating from computer memory.", ".Net Framework Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
Environment::Exit(1);
}
When this block of code was executed with my program, I get the following error message (In double quotations):
"error C2664: 'System::Security::Principal::WindowsPrincipal::WindowsPrincipal(System::Security::Principal::WindowsIdentity ^)' : cannot convert parameter 1 from 'System::Object ^' to 'System::Security::Principal::WindowsIdentity ^'"
the remaining error messages are (In double quotations):
"1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"
Could anyone point out something that I could edit that could make the compiler accept or work, any suggestions or personal solutions are appreciated .
|
|
|
|
|
Brandon-hbx12000 wrote: Object ^identity = WindowsIdentity::GetCurrent();
The problem is in the very first word. Why would you "anonimize" whatever it is GetCurrent() returns? Use real types where ever you can.
|
|
|
|
|
thank you
|
|
|
|
|
You're welcome.
|
|
|
|
|
You have stored the return from your call to WindowsIdentity::GetCurrent() as an object reference. You are then sending that object reference to the WindowsPrincipal() constructor, which expects a WindowsIdentity reference as documented here[^]. The compiler is complaining because it does not feel able to promote an object reference to a higher level. Save your WindowsIdentity object as a WindowsIdentity reference.
|
|
|
|
|
thank you
|
|
|
|
|
|
Hi all,
Hoping you can help me out. I've been trying to track down a handle leak in our product for the last few days, and I've gotten to the point where I suspect something is happening outside of our code. It seems that everytime my application calls _beginthread, there is 5 handles that leak. This happens to be our Server application, which receives many requests and calls to _beginthread, so after a period of time, this gets ugly.
This application is compiled with /clr to use code written in a .DLL for LDAP Authentication. But regardless of whether nor not any C#/DLL code gets ran, we're still leaking. I commented EVERYTHING out, except a call to _beginthread. Inside the thread proc, all I do is call _endthread... And the problem still occurs - 5 handles on every call.. This is verified using Process Explorer and the WinDbg tool.
If I turn off the /clr flag, and the problem goes away...
I did a !htrace in WinDbg, and this is what its showing me..
Outstanding handles opened since the previous snapshot:
--------------------------------------
Handle = 0x00000240 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21575: mscorwks!Thread::AllocHandles+0x0000009b
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000023c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21569: mscorwks!Thread::AllocHandles+0x0000008f
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000238 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b2155d: mscorwks!Thread::AllocHandles+0x00000083
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000234 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21551: mscorwks!Thread::AllocHandles+0x00000077
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000022c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4680: ntdll!ZwDuplicateObject+0x0000000c
0x77963d92: KERNEL32!DuplicateHandle+0x0000012b
0x72b2365f: mscorwks!Thread::InitThread+0x00000174
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
0x77c916c3: ntdll!__RtlUserThreadStart+0x00000023
0x77c91696: ntdll!_RtlUserThreadStart+0x0000001b
--------------------------------------
I've exhausted everything I can - have you seen this before? What do you recommend in further debugging the problem? I'm using VS.2008. I don't believe you can specify in the C++ Project the .NET version (thought perhaps it was fixed in a later version) ..
Any help and or suggestions you may have would be greatly appreciated, thanks.
Mike
|
|
|
|
|
hi,
I have an aplication whose view is based in TabControl. It has three tab and one of them have a Edit control. I'd like show text in this edit control when I press a button. I thought do a global variable that keep a valor, for example 1, and in the method, to do a control that show text only if the variable have valor 1.
But my problem is after press button, don't happen something. I think that I must to update the view with the method onUpdate or something like that.. but I dont know how.
What do you think?
This is my aplication:
http://i54.tinypic.com/1e9qtx.png
This is code :
http://www.megaupload.com/?d=1QT43LOQ[^]
|
|
|
|
|
|
In C++ on VS 2005 , createfile API fails with Invalid file handle error in below scenrio.
1.Consider user A and user B are both part of administrator group and i logged in to machine as user A and started one service application with user B. This program creates files on mapped network drive.
so i started this program with user B then below createfile API fails with invalid handle error when i try to create a file on mapped network drive ,though user A and B both part of administrator group on windows.
This happens on windows server 2003 and 2008 also.
In Win 2008 i turned off UAC but same behaviour.
Any other setting need to be done while creating mapped network drive ?
Usre who is creating a mapped network drive is the only one who can write file to it ?
While creating a network drive i logged in as user A, but file is created on this drive by user B , but since both are part of administrator why user B is NOT allowed to create a file on mapped network drive ?
Thanks.
//code i tried
DWORD dwAccess = CREATE_NEW;
HANDLE hFile = CreateFile(sTempFile, GENERIC_WRITE,
0, NULL, dwAccess, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD errCode = GetLastError();
|
|
|
|
|
I have following header file and library. using this header file and library i want create DLL in VC++. then this DLL I can use in vb.net. I added this header file and library file in my vc++ project but at the time of create build it gating error.
i think I need _declspec(dllexport) int capture_data(unsigned char ** raw_image, unsigned char **
fmr_data, int templateLen[]) this function Please suggest me how can i Add this function.
1. MORPHO_Types.h
2. MORPHO_TemplateList.h
3. MORPHO_FieldList.h
4. MORPHO_User.h
5. MORPHO_UserList.h
6. MORPHO_FieldDescriptor.h
7. MORPHO_Database.h
8. MORPHO_Device.h
9. MORPHO_Errors.h
10. MORPHO_Image.h
11. MORPHO_Interface.h
1 MORPHO_SDK.lib (functions that communicate with device)
2.MORPHO_SDK_Image.lib (functions that display images from device)
my mail id is ravi.ranadive@gmail.com
|
|
|
|
|
Just asking an interview question.
In Windows perspective what is the difference between a user dump and kernel dump?
|
|
|
|
|
Consider: what is the difference between user space and kernel space?
Also consider whether this really has anything at all to do with Managed C++/CLI.
|
|
|
|
|
Pls, check my codes. I added app.config file into project. codes are
<configuration>
<connectionStrings>
<add name ="SQLConnection" providerName="Oracle.DataAccess.Client"
connectionString="Data Source=localhost:1521/orcl; user id=scott; password=tiger"/>
</connectionStrings>
</configuration>
In C++/CLI file I tried to connect Oracle DB but failed. Codes are like below
#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::Common;
using namespace System::Configuration;
using namespace Oracle::DataAccess::Client;
int main(array ^args)
{
try{
String^ provider = ConfigurationManager::ConnectionStrings["SQLConnection"]->ProviderName;
DbProviderFactory^ factory = DbProviderFactories::GetFactory(provider);
DbConnection^ conn = factory->CreateConnection();
String^ connection = ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString;
conn->ConnectionString = connection;
conn->Open(); //Exception Occurs!
}
catch (Exception^ e) {
Console::WriteLine(e->Message);
}
return 0;
}
Exception is ora-12541 No Listener. But "tnsping orcl" is done well. and I executed "lsnrctl start".
I need your advice. Thanks in advance.
Best Regards.
Joseph Hwang
|
|
|
|
|
hello.
how do i realize the interaction between managed and unmanaged code inside a mixed assembly dll? assume the dll exposes an unmanaged API and shall be callable from unmanaged client code.
I understand that by using delegates I can rout unmanaged functions to managed functions, however I need to create managed objects first.
how can the creation or initialization of managed objects be achieved if user entrypoints may only contain unmanaged code and automated entry-points should be deactivated due to the dll load bug?
thanx for any advice
modified on Friday, September 9, 2011 6:13 AM
|
|
|
|
|
It's not clear what you're asking. Can you restate the question in one sentence?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|