|
COM here stands for Component Object Model and not a serial port.
You should put the VB application in the Run registry key so that it starts up automatically after a reboot and then call the button click routines in the Form load event so that it connects automatically to the scanner.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi all,
I created a ActiveX(C# and .NET).
now,i've register it in my computer. and use <object> tag in html file.
when i open the IE and specify the html address, what's UsageMode? Designtime? Runtime?
how to differentiate this two mode?
i implement LicenseProvider in ActiveX,and write code in GetLicense procedure.
if (context.UsageMode == LicenseUsageMode.Designtime)
{
System.Windows.Forms.MessageBox.Show("Designtime");
}
if (context.UsageMode == LicenseUsageMode.Runtime)
{
System.Windows.Forms.MessageBox.Show("Runtime");
}
but, it always show Designtime.
|
|
|
|
|
I’m getting a assertion in below code. What could be the prolbem.
bool AxControl::CreateOleClientInstance(CLSID clsidActual)
{
clsid = clsidActual;
AfxEnableControlContainer();
pDoc = new COCXDocument();
pDoc->OnNewDocument();
pClient = new COCXClientItem(pDoc);
CoInitialize(NULL);
pClient->CreateNewItem(clsidActual);
pClient->m_lpObject->QueryInterface(
IID_IDispatch, (void**)&m_lpObjectdispatch);
return true;
}
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
...you know, I googled COCXClientItem, and there WAS NOTHING.
What is it? Did you write the code? Derive it from some other class that is publicly documented?
Assertions usually crash the application (by design), so I assume that the code you displayed above actually compiled. That means that COCXClientItem must be in one of your header files, or would have generated a compiler error.
I would suspect that the clsidActual variable did not pass some simple error checking test (for instance, checking for an invalid value). You could do that yourself before you passed it to COCXClientItem->CreateNewItem ().
This most closely resembles your code example: COleClientItem::CreateNewItem[^], except that it has four function parameters, whereas yours has only one.
|
|
|
|
|
Hello All,
When we right click on any mail present in inbox then we get a context menu.
I need to customize that context menu.
Can anybody help me?
|
|
|
|
|
I am trying to access a c++ created DLL from within Excel, with semi-success only:
I've followed the following tutorial EXACTLY: http://newtonexcelbach.wordpress.com...ng-excel-to-c/
Now, when I try and use the dll-functions that I've declared in the VB code, the function GetPrice(), which takes no arguments and simply returns a number, works fine.
However, as soon as I create a dll-function which takes input arguments, I get a #VALUE error in the cell in Excel ("A value used in formula is of the wrong data type" ).
I've downloaded the complete sample from the URL above and get the same error when running it (after recalculating the formulas).
I've created a test 'proxy' function (in which the code can be stepped through, which calls the dll function) to ensure that values sent to the dll function are indeed of type double and that seems to be the case ...
This guy seems to have had the same problem, however no solution was posted:
http://www.ozgrid.com/forum/showthread.php?t=54245[^]
Any help / tips would be greatly appreciated!
g
excell dll newbie
|
|
|
|
|
when I am Loading the EXE file I am getting this error. How can I rectiy this
error
Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
Here is the Code Below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
using Microsoft.Office.Interop.Word;
namespace WordCheckPercent
{
public partial class Form1 : Form
{
Match m;
Regex r;
FileStream fsr;
FileStream fsw;
StreamReader sr;
StreamWriter sw;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = false;
File.Delete("c:\\tmp.txt");
File.Delete("c:\\tmp1.txt");
//Word.Application app = new Word.ApplicationClass();
Microsoft.Office.Interop.Word.ApplicationClass app = new Microsoft.Office.Interop.Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
string docpath = "";
foreach(string str in Directory.GetFiles(textBox1.Text))
{
if((str.EndsWith(".doc"))||(str.EndsWith(".rtf")))
{
docpath=str;
break;
}
}
object file =docpath;
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open
(ref file, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
// string text = data.GetData(DataFormats.Text).ToString();
//string text = data.GetData(DataFormats.Text).ToString();
string text = data.GetData(DataFormats.Text).ToString();
// MessageBox.Show(text);
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);
fsw=new FileStream("c:\\tmp.txt",FileMode.Create,FileAccess.Write);
sw=new StreamWriter(fsw);
sw.Write(text);
sw.Close();fsw.Close();
fsr = new FileStream("c:\\tmp.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fsr);
string line = sr.ReadToEnd();
line = Regex.Replace(line, " ", "\r\n");
line = Regex.Replace(line, @"([\r\n]+)", "\r\n");
sr.Close(); fsr.Close();
fsw = new FileStream("c:\\tmp1.txt", FileMode.Create, FileAccess.Write);
sw = new StreamWriter(fsw);
sw.Write(line);
sw.Close(); fsw.Close();
fsr = new FileStream("c:\\tmp1.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fsr);
int countdoc = 0;
while ((line = sr.ReadLine()) != null)
{
if (line != "")
{
countdoc = countdoc + 1;
}
// MessageBox.Show(line);
}
sr.Close(); fsr.Close();
MessageBox.Show("Source file Word count :- "+countdoc.ToString());
////////////////////////////////////////////////////////////
progressBar1.Visible = true;
this.progressBar1.Maximum = countdoc;
this.progressBar1.Minimum = 0;
this.progressBar1.Step = 1;
File.Delete(textBox1.Text + "\\error.txt");
fsr = new FileStream("c:\\tmp1.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fsr);
bool status = false;
Microsoft.Office.Interop.Word.ApplicationClass winword = new Microsoft.Office.Interop.Word.ApplicationClass();
Object o = System.Reflection.Missing.Value;
while ((line = sr.ReadLine()) != null)
{
m = Regex.Match(line, @"([a-z])([^a-z])([a-z])", RegexOptions.IgnoreCase);
if (m.Success)
{
}
else
{
line = Regex.Replace(line, @"([a-z])([^a-z])", "$1", RegexOptions.IgnoreCase);
line = Regex.Replace(line, @"([^a-z])([a-z])", "$2", RegexOptions.IgnoreCase);
}
status = winword.CheckSpelling(line, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
if (line.Length == 1)
{
if ((line == "i") || (line == "I") || (line == "a") || (line == "A"))
{
status = true;
line = " " + line + " ";
}
else
{
m = Regex.Match(line, @"[a-z]", RegexOptions.IgnoreCase);
if (m.Success)
{
status = false;
line = " " + line + " ";
}
else
{
status = true;
}
}
}
if (status == false)
{
fsw = new FileStream(textBox1.Text + "\\error.txt", FileMode.Append, FileAccess.Write);
sw = new StreamWriter(fsw);
sw.WriteLine(line);
sw.Close(); fsw.Close();
}
progressBar1.PerformStep();
}
winword.Quit(ref nullobj, ref nullobj, ref nullobj);
progressBar1.Visible = false;
////////////////////////////////////
int counttxt = 0;
fsr = new FileStream(textBox1.Text + "\\error.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fsr);
while ((line = sr.ReadLine()) != null)
{
if (line != "")
{
counttxt = counttxt + 1;
}
}
sr.Close(); fsr.Close();
MessageBox.Show("Total Error count:- "+counttxt.ToString());
fsw = new FileStream(textBox1.Text+"\\DataAccuracy.txt", FileMode.Create, FileAccess.Write);
sw = new StreamWriter(fsw);
double mu=(counttxt*100);
double final=100-(mu/countdoc);
int ab = docpath.LastIndexOf("\\");
string filnam = docpath.Substring(ab + 1);
sw.WriteLine("###########################" + filnam + "###########################");
sw.WriteLine("\r\n\r\n");
sw.WriteLine("Source file Word count :- " + countdoc);
sw.WriteLine();
sw.WriteLine("Total Error count:- " + counttxt);
sw.WriteLine();
sw.WriteLine("Data Accuracy for given file is :- "+final+"%");
sw.Close(); fsw.Close();
this.Close();
File.Delete("c:\\tmp.txt");
// File.Delete("c:\\tmp1.txt");
}
private void button2_Click(object sender, EventArgs e)
{
if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
this.textBox1.Text = this.folderBrowserDialog1.SelectedPath;
}
}
}
|
|
|
|
|
This is the COM Forum. If you post this at the .NET Framework Forum, you'll probably get a better response.
But, it's probably just a version problem. As I recall, there is a method to specify the correct version.
|
|
|
|
|
Hello,
I have COM component. It contains one GetRecordSet method which takes one of the parameter ADODB.Connection and return ADODB.Recordset. But while accessing through ASP it gives error Invalid Procedure call or argument.
Same method works fine from VB and VC.
If you have any solution for it,then plz let me know.
Thanks !
Regards,
Vibhuti
|
|
|
|
|
I have a C# class which contains a jagged array as one of its properties exposed to COM:
string[][] Measurements
The property vcan easily be read/set by .Net applications but I was asked to expose it to COM applications (namely VB6 and VBScript). I was able to expose all the properties to COM except this jagged array because there's no marshalling support for jagged arrays. So, I've tried to change it from string[][] to string[,] Measurements, but now I can see this property in VB6 and when I call it I can't get the data populated in a VB array. LBound and UBound give the correct array size but this code give wrong type error:
For r = LBound(objClass.Measurements, 1) To UBound(objClass.Measurements, 1)
For f = LBound(objClass.Measurements, 2) To UBound(objClass.Measurements, 2)
sMeasurements = sMeasurements & objClass.Measurements[r, f])
Next
Next
And this code returns the data scrambled: the values in objClass.Measurements(0,0) then objCard.Measurements(1,0) then (0,1) then (1,1) etc. instead of (0,0) then (0,1) then (0,2) then (0,3) etc.:
For Each sReading In objClass.Measurements
Debug.Print sReading
Next
Any idea how I should declare the jagged array in the C# module and how I should call it from VB6 or VBScript?
Thanks,
Martha
|
|
|
|
|
AFAIK, this example demonstrates jagged array in VB:
Dim v As Variant, i As Long, j As Long
v = Array(Array(1, 2), Array(3, 4, 5))
For i = LBound(v) To UBound(v)
For j = LBound(v(i)) To UBound(v(i))
Debug.Print v(i)(j)
Next
Next
It can be also applied to "v() As Variant".
With best wishes,
Vita
modified on Wednesday, March 25, 2009 5:30 AM
|
|
|
|
|
Hi Guys. My first post in this forumn so please bare with me. I have built an app that references office 12 because I have Office 2007 installed on my PC. However, when I build the exe and install this on another machine it doesn want to work. Is it because the other machine has office 2003 installed on it? Is there an easy way for me to get around this other than having to uninstall Office 2007 from my machine and installing Office 2003 so I can reference the correct com file and build the project with it??
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
The simplest and most obvious solution is to write a function that determines what version of Office is installed on the LOCAL MACHINE, and then references the existing library component based on that condition.
|
|
|
|
|
Thanks for the reply Baltoro but I have no idea how to do this. Do you know of any posts that shows how to do this? I'm just on Google and can't find anything or I might be searching for the wrong thing.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
All COM classes have registry entries (this is what the COM Library uses to activate objects). Searching the registry is pretty simple. As I recall, Microsoft applications have thousands of registry keys and values. I would guess enumerating, HKEY_LOCAL_MACHINE\SOFTWARE subkeys for Microsoft subkey, and then specific subkeys for Office 12, and eventually, you're looking for a Current Version subkey and value.
Also, you might try searching here: Object Library Reference for Microsoft Office 12[^]
|
|
|
|
|
Hi
I am implementing security on Contact base smart card which follows scosta template.In card structure ef is directly under DF and DF is directly under MF. According to the template i am implementing security on elementary file(both sac and sae attributes are specified at time of creation in fcp) according to security condition read and update of record requires verification of pin(which is already defined in pin file).
Problem is that after implementing the security attributes on card now also my card is not following that,after selecting the file i can directly read and write on record, card does not ask for verification of pin.
please help me asap...............
|
|
|
|
|
hi how did u created MF, DF and EF files in smartcard please let me know.
|
|
|
|
|
how i can display an icon(bitmap,png,...) on a button in an activex control. i have used LoadImage function and obtained the button without an icon as a result. When i used this function in a dialog based MFC application it worked. what is the difference of activex control ?
here what i used;
HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0);
mb_PickUp.SetIcon(hIcon);
thanks in advance
|
|
|
|
|
Is GetModuleHandle(NULL) now getting a different resource handle than before?
|
|
|
|
|
actually in a dialog based application everything is fine for GetModuleHandle(NULL) funtion but in activex it returns NULL so it seems that is the problem. any suggestion to fix this.
thanks
|
|
|
|
|
|
i use the activex in the browser so what should be the path of dll/exe that my activex lives in. iexplorer.exe ?
|
|
|
|
|
What is your activeX written using, MFC? ATL? Win32? Whatever it is, though you could find the name/path to pass there may be a function called something like GetResourceInstance() you can call which will do it for you, have a look.
|
|
|
|
|
it worked thanks very much.
|
|
|
|
|
Hello, is it possible to create a COM objects structure as below:
In a dll library I define:
class T1
{
public:
STDMETHOD(Method)();
}
STDMETHODIMP T1::Method()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
return S_OK;
}
which implements interface:
interface IT1 : IDispatch
{
[id(1)] HRESULT Method();
};
coclass T1
{
[default] interface IT1;
};
and then I would like to have:
class T2 : public T1
{
}
I would like to create a COM objects from the class T2 and have all the functionality provided by class T1. E.g. I would like to call:
CComQIPtr<it2> spiT1(piT2);
spiT1->Method();
</it2>
Anyone can help?
|
|
|
|
|