|
We used AJAX to call a page by passing some parameters through querystring. Based on the parameters, the page will perform some operations. IE always caches the files and when the same page is called with some other parameters, sometimes IE takes the cached page with old parameters and because of our validations, it says that duplicate not allowed. Is there a way to force IE to always get the file from the server and not from Cache
|
|
|
|
|
I have a 3rd party COM application that I use to retrieve 3d map information over the web. All the methods work fine accept one method. That method (SaveRenderToFile) saves a render of the present image to a file on the computer. Occasionally (about 1 in every hundred calls) it will lock the application and sometimes kill it.
I don’t know how to prevent this from happening. I NEED the image rendered. I think I’m screwed and I’ll have to hope that the company fixes its method.
Here is my code…
/*
* Function: SaveImageToFile
* Save the RenderToAFile
* Returns: path to the saved image if successful.
*/
BSTR CTE3DWindow::SaveImageToFile()
{
ISnapShot2Ptr pISnapShot2;
BSTR image = L"no image";
long iPicQual = -1;
char szBuffer[256];
CoInitialize(NULL);
pITE5.QueryInterface(IID_ISnapShot2, (ISnapShot2**)&pISnapShot2);
pISnapShot2->PutRenderQuality(0);
sprintf(szBuffer, "CTE3DWindow::SaveImageToFile entering try->SaveRenderToFile");
LogDebugInfo(szBuffer);
try
{
image = pISnapShot2->SaveRenderToFile();
}
catch(_com_error const &e)
{
sprintf(szBuffer, "CTE3DWindow::SaveImageToFile failed was ");
strcat(szBuffer, (char*)e.Description());
LogDebugInfo(szBuffer);
return image= L"no image";
}
sprintf(szBuffer, "CTE3DWindow::SaveImageToFile Completed SaveRenderToFile, image is ");
strcat(szBuffer, (char*)image);
LogDebugInfo(szBuffer);
CoUninitialize();
return image;
}//END SaveImageToFile
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
The following is a serious error:
BSTR image = L"no image";
A BSTR is not just a wide string. First it's prefixed with a length and the length is ***BEFORE*** the position the pointer points. Secondly a specific allocator is assumed. To fix this error make the following change:
BSTR image = SysAllocString(L"no image");
You also should add a call to SysFreeString to free the string when it's no longer needed. An understanding of BSTR s is essential if you're going to use COM in C/C++ without any wrappers (and probably even if you are).
The calls to CoInitialize and CoUninitialize also worry me. Although this need not be a mistake (I'd have to see more code) the normal pattern is to initialise COM once when the app starts and uninitialise it once when the app exits. You should not uninitialise COM while COM objects still exist -- that's what it look like you may be doing.
Steve
|
|
|
|
|
Thank You EVERY MUCH for the feedback it may not have solved my problem but I'm sure it will help my application to be better.
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Hi all,
I wrote a very simple user control in C#, and I'm trying to access it from my C++/MFC code. The control contains a single label in it. Here's the control code itself:
namespace HelloCom {
[Guid("F0AE1BB2-A840-4341-B785-D8A54C81E643")]
public interface HelloCom {
}
[Guid("111DCC11-900D-431c-B3A0-4B95C539A47D")]
public partial class HelloComImpl : UserControl, HelloCom {
public HelloComImpl() {
InitializeComponent();
}
}
}
Here's what I've done so far:
* Signed my control with a strong key
* Clicked the "expose assembly to COM interop" and "make visible to COM" options
* regasm HelloCom.dll /tlb:HelloCom.tlb
* gacutil -i HelloCom.dll
However, despite all this, I still cannot see my control in the Toolbox on the C++ side, nor can I insert it via the "Insert ActiveX Control" menu option. What am I doing wrong ?
|
|
|
|
|
hi all,
how to access a COM component developed in vc++6.0 from ASP.net?
what r the issues need to be considered in this case??
Thanks in advance.
Prashanth.v
|
|
|
|
|
I'm not sure, but it would be VB way. You need to add reference to that component in your project and use it in like VB.
|
|
|
|
|
I created a .NET class libray, and I use it in a Win32 Console app.
It works fine, but the smart pointer Release() method, don't call the .NET class destructor? What did I wrong?
Win32:
#import "p1.tlb"
void f()
{
p1::IClass1Ptr p("My1.Class1");
p->Show();
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
f();
return 0;
}
.NET class lib:
[ComVisible(true)]
[GuidAttribute("3DAF8E7A-ACD0-4bd9-B275-04F4F802948B")]
[InterfaceTypeAttribute(ComInterfaceType::InterfaceIsDual)]
public interface class IClass1
{
void Show();
};
[ComVisible(true)]
[ProgIdAttribute("My1.Class1")]
[GuidAttribute("BA9367CA-6707-4060-A42C-34D2A3DEBC05")]
[ClassInterfaceAttribute(ClassInterfaceType::None)]
public ref class Class1 : IClass1
{
public:
virtual void Show()
{
MessageBox::Show(m_str);
}
public:
Class1()
{
m_str = gcnew String("Class1()");
}
~Class1()
{
if(m_str) delete m_str;
this->!Class1();
}
!Class1()
{
}
private:
String^ m_str;
};
whole source:
http://bmfnik.hu/szokeimre/prog/com_ptr.ZIP
|
|
|
|
|
I developed a COM add-in for Outlook 2003 with Visual Studio 2005.
I added an msoControlPopup to the menu bar of Outlook and then added an msoControlButton to the popup. The button would then initialize a Windows.Forms.Form object.
However, each time I start outlook, I can only run the add-in for once. After I close the Form, the button gave no response at all if I click it.
Some of the codes in Connect.cs are as follows:
public class Connect : Object, Extensibility.IDTExtensibility2
{
CommandBar menuBar;
CommandBarControl commandBarControl_CM;
public Connect()
{
}
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
}
public void OnAddInsUpdate(ref System.Array custom)
{
}
public void OnStartupComplete(ref System.Array custom)
{
//applicationObject = (Outlook.Application)applicationObject;
//Acquire the "Menu Bar" and create a new control on it
menuBar = ((Outlook.Application)applicationObject).ActiveExplorer().CommandBars["Menu Bar"];
commandBarControl_CM = menuBar.Controls.Add(MsoControlType.msoControlPopup, 1, "", 6, true);
commandBarControl_CM.Visible = true;
commandBarControl_CM.Caption = "Calendar Management";
//Add button(s) to the newly created control
CommandBarPopup commandBarPopup_CM = (CommandBarPopup)commandBarControl_CM;
CommandBarControl commandBarControl_SI = commandBarPopup_CM.Controls.Add(
MsoControlType.msoControlButton, 1, "", 1, true);
commandBarControl_SI.Visible = true;
commandBarControl_SI.Caption = "Show Info";
//Add button event handler(s)
CommandBarButton button_showinfo = (CommandBarButton)commandBarControl_SI;
button_showinfo.Click += new _CommandBarButtonEvents_ClickEventHandler(button_showinfo_Click);
}
public void OnBeginShutdown(ref System.Array custom)
{
}
private void button_showinfo_Click(CommandBarButton Ctrl, ref Boolean CancelDefault)
{
System.Windows.Forms.Form form_CalMng = new Form_CalMng();
form_CalMng.Show();
}
private object applicationObject;
private object addInInstance;
}
|
|
|
|
|
Somebody help me, please......
|
|
|
|
|
Hi
Question 1:
When we create an COM object in a Process where does the memory of the COM objects get allocation?
Question 2:
Does the memory allocated to the COM object contributed to increase in Virtual memory of the process where it is instantiated.?
Question 3:
What is the relation between virtual memory of a process and private bytes of the process?
for Ilanthendral(KillerInstincts)
|
|
|
|
|
R.ilan thendral wrote: Question 1:
When we create an COM object in a Process where does the memory of the COM objects get allocation?
Wherever the code that implements the class factory allocates it. Typically this will be on one of the heaps but sometimes a small number of static objects are used.
Question 2:
Does the memory allocated to the COM object contributed to increase in Virtual memory of the process where it is instantiated.?
Potentially. The heap manager manages a large block of virtual address space for each heap, so sometimes allocating from the heap can be satisfied from the existing virtual address space allocated to the heap, and sometimes the heap has to grow to satisfy the new allocation.
Question 3:
What is the relation between virtual memory of a process and private bytes of the process?
It's hard to do justice to that question in a small amount of space. The virtual address space is how the process views memory; at any time, most of the virtual address space isn't backed by anything - if you try to write to or read from them, you just get an access violation. Virtual addresses can be mapped to memory-mapped files, shared memory sections, can be marked as reserved, or can point to memory that can only be accessed by this process - these are 'private bytes'.
Task Manager confuses everything by referring to 'private bytes' as 'VM Size'.
In turn, only some of the process's virtual addresses are actually in physical memory at any given time. The working set ('Mem Usage' in Task Manager) is the set of pages belonging to the process (memory-mapped files, shared, or private) which are currently in physical memory. The processor and operating system work together to give the illusion that the code and/or data are all accessible; if the process references (reads from or writes to) a page not currently in physical memory, the processor raises a page fault exception, which the OS handles by reading the page from disk, then setting a data structure (the page table entry) to point to the physical memory containing that page.
|
|
|
|
|
Hello all,
I have a COM component on a remote server with no DllSurrogate = "" value set in the remote registry.
So, the instantion could not be done in the server side only.
I made a method to access the remote registry primitives, using the pipe \\PIPE\winreg and also using the rpc.rcacn_np transport. So, this way I'm able to modifying the registry remotely, putting the DllSurrogate="" and performing the COM instantiation.
Everything is working fine, but now I must do all of this without file and print sharing, which means that I'll not be able to use the PIPE anymore. So I'm looking for some COM with DllSurrogate="" already enabled that expose some function to modify my component. Or some service working at port 135 or 445 with some exposed methods to do the same thing, this way I can access using the rpc.rcacn_ip_tcp.
So, any ideas. Thanks in advance.
Raphael Amorim Dantas Leite
|
|
|
|
|
Hello,
In the case you described I prefer to use WMI (Windows Management Instrumentation). It's an ultimate tool for making a kind of administrative work both on a local and remote computer under Windows XP & 2000. WMI "System Registry Provider" gives a full control on registry DB. You have to have administrative rights to perform any registry write operations on a remote PC, of course.
If you are interested in using WMI, write me, I may share a simple project with you as an example of administration via WMI.
Regards,
ISerik
|
|
|
|
|
Using WMI from Linux? The only way is using the COM WBEM Scripting locator and it's not automated by default. We MUST change the registry like I said.
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|
|
i want to programatically call WindowActivate event of word object..
how can i?
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Hello, all.
I have windows service. This following code in a application:
CoInitialize(0);
HRESULT hr;
SHDocVw::IShellWindowsPtr spSHWinds;
hr = spSHWinds.CreateInstance (__uuidof(SHDocVw::ShellWindows));
I get error: "Class isn't register".
|
|
|
|
|
It may be due to that a Service by default runs on a different (non visible) windows station.
Try setting the Service up to start as a specific user.
1. Go to the Start Menu, Select Run and type "services.msc" and press return.
2. Select your Service, right click and choose "Properties"
3. Select the "LogOn" tab and enter in the details of a valid user.
Or it could be that you need to check the "Allow Service to Interact with
Desktop" checkbox.
regards,
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
I create service with SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS and SERVICE_INTERACTIVE_PROCESS
|
|
|
|
|
Did you try my first suggestion of changing the Service to run as a specific user account ?
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
Ok, if the service run in other user account it work. But it is necessary to start service from LocalSystem account.
|
|
|
|
|
Then you need to impersonate another user, see the LogonUser() and ImpersonateLoggedOnUser() functions.
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
I am sorry. And it is impossible little bit more in detail? I all time developed programs on a low level. Simply we had a situation, that more anybody is not present at the moment, and to make it is necessary urgently.
|
|
|
|
|
Try something like this:
<code>TCHAR szDomain[] = 'DomainName';
TCHAR szUserName[] = 'Username';
TCHAR szPassword[] = 'Password';
HANDLE hUser = NULL;
BOOL bLoggedOn = LogonUser(szUserName, szDomain, szPassword, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &hUser);
if(!bLoggedOn)
{
DWORD dwErr = GetLastError();
return;
}
if(!ImpersonateLoggedOnUser(hUser))
{
DWORD dwErr = GetLastError();
return;
}
CoInitialize(0);
SHDocVw::IShellWindowsPtr spSHWinds;
HRESULT hr = spSHWinds.CreateInstance (__uuidof(SHDocVw::ShellWindows));
RevertToSelf();
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|